<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic Re: pyodbc login timeout expired when connecting to Lakehouse SQL endpoint using Service Principal in Data Warehouse</title>
    <link>https://community.fabric.microsoft.com/t5/Data-Warehouse/pyodbc-login-timeout-expired-when-connecting-to-Lakehouse-SQL/m-p/4720608#M3165</link>
    <description>&lt;P&gt;Hi&amp;nbsp;&lt;a href="javascript:void(0)" data-lia-user-mentions="" data-lia-user-uid="1282779" data-lia-user-login="ThucLe" class="lia-mention lia-mention-user"&gt;ThucLe&lt;/a&gt;&amp;nbsp;,&lt;/P&gt;
&lt;P&gt;If your question has been answered, kindly mark the appropriate response as the Accepted Solution. This small step goes a long way in helping others with similar issues.&lt;/P&gt;
&lt;P&gt;We appreciate your collaboration and support!&lt;/P&gt;
&lt;P&gt;&lt;STRONG&gt;Best regards,&lt;/STRONG&gt;&lt;BR /&gt;&lt;STRONG&gt;LakshmiNarayana&lt;/STRONG&gt;&lt;/P&gt;</description>
    <pubDate>Thu, 05 Jun 2025 04:48:39 GMT</pubDate>
    <dc:creator>v-lgarikapat</dc:creator>
    <dc:date>2025-06-05T04:48:39Z</dc:date>
    <item>
      <title>pyodbc login timeout expired when connecting to Lakehouse SQL endpoint using Service Principal</title>
      <link>https://community.fabric.microsoft.com/t5/Data-Warehouse/pyodbc-login-timeout-expired-when-connecting-to-Lakehouse-SQL/m-p/4710089#M3097</link>
      <description>&lt;P&gt;I'm running into an issue trying to connect to a Lakehouse SQL endpoint using pyodbc and a &lt;STRONG&gt;service principal&lt;/STRONG&gt; in Python. Despite verifying that the service principal works (I successfully authenticated using SSMS with the same credentials), I get the following error in my script:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;pyodbc.OperationalError: ('HYT00', '[HYT00] [Microsoft][ODBC Driver 18 for SQL Server]Login timeout expired (0) (SQLDriverConnect)')&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;H3&gt;&lt;STRONG&gt;Environment &amp;amp; What I've Tried:&lt;/STRONG&gt;&lt;/H3&gt;&lt;UL&gt;&lt;LI&gt;&lt;P&gt;Using &lt;STRONG&gt;Python with pyodbc&lt;/STRONG&gt;&lt;/P&gt;&lt;/LI&gt;&lt;LI&gt;&lt;P&gt;Target: &lt;STRONG&gt;Lakehouse SQL endpoint&lt;/STRONG&gt;&lt;/P&gt;&lt;/LI&gt;&lt;LI&gt;&lt;P&gt;Authentication: &lt;STRONG&gt;Service Principal (Client ID + Secret)&lt;/STRONG&gt;&lt;/P&gt;&lt;/LI&gt;&lt;LI&gt;&lt;P&gt;Verified network/firewall is not an issue (connection via SSMS using the same service principal works fine)&lt;/P&gt;&lt;/LI&gt;&lt;LI&gt;&lt;P&gt;Using ODBC Driver 18&lt;/P&gt;&lt;/LI&gt;&lt;LI&gt;&lt;P&gt;Tried setting ConnectRetryCount to handle retries&lt;/P&gt;&lt;/LI&gt;&lt;/UL&gt;&lt;P&gt;&lt;STRONG&gt;Here's a redacted version of my code:&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="python"&gt;import pyodbc

TENANT_ID = "&amp;lt;tenant-id&amp;gt;"
CLIENT_ID = "&amp;lt;client-id&amp;gt;"
CLIENT_SECRET = "&amp;lt;client-secret&amp;gt;"

server = "&amp;lt;sql-endpoint&amp;gt;.datawarehouse.fabric.microsoft.com"
database = "&amp;lt;database-name&amp;gt;"
username = CLIENT_ID
password = CLIENT_SECRET

connection_string = f"Driver={{ODBC Driver 18 for SQL Server}};Server={server};Database={database};Authentication=ActiveDirectoryServicePrincipal;UID={username};PWD={password};ConnectRetryCount=4"

print("Attempting connection...")
conn = pyodbc.connect(connection_string)  # Fails here with login timeout

# Sample query
cursor = conn.cursor()
cursor.execute("SELECT * FROM sys.tables")
rows = cursor.fetchall()
for row in rows:
    print(row)
conn.close()&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 28 May 2025 08:03:11 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/Data-Warehouse/pyodbc-login-timeout-expired-when-connecting-to-Lakehouse-SQL/m-p/4710089#M3097</guid>
      <dc:creator>ThucLe</dc:creator>
      <dc:date>2025-05-28T08:03:11Z</dc:date>
    </item>
    <item>
      <title>Re: pyodbc login timeout expired when connecting to Lakehouse SQL endpoint using Service Principal</title>
      <link>https://community.fabric.microsoft.com/t5/Data-Warehouse/pyodbc-login-timeout-expired-when-connecting-to-Lakehouse-SQL/m-p/4711566#M3108</link>
      <description>&lt;P&gt;Try to include Authority with your Tenant ID&lt;/P&gt;&lt;P&gt;Authority=&lt;A href="https://login.microsoftonline.com/" target="_blank"&gt;https://login.microsoftonline.com/&lt;/A&gt;&amp;lt;tenant-id&amp;gt; is required for service principal auth to work.&lt;/P&gt;</description>
      <pubDate>Thu, 29 May 2025 07:16:29 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/Data-Warehouse/pyodbc-login-timeout-expired-when-connecting-to-Lakehouse-SQL/m-p/4711566#M3108</guid>
      <dc:creator>BhavinVyas3003</dc:creator>
      <dc:date>2025-05-29T07:16:29Z</dc:date>
    </item>
    <item>
      <title>Re: pyodbc login timeout expired when connecting to Lakehouse SQL endpoint using Service Principal</title>
      <link>https://community.fabric.microsoft.com/t5/Data-Warehouse/pyodbc-login-timeout-expired-when-connecting-to-Lakehouse-SQL/m-p/4713778#M3119</link>
      <description>&lt;P&gt;Hi&amp;nbsp;&lt;a href="javascript:void(0)" data-lia-user-mentions="" data-lia-user-uid="1282779" data-lia-user-login="ThucLe" class="lia-mention lia-mention-user"&gt;ThucLe&lt;/a&gt;&amp;nbsp;,&amp;nbsp;&lt;BR /&gt;Thanks for reaching out to the Microsoft fabric community forum.&lt;BR /&gt;&lt;a href="javascript:void(0)" data-lia-user-mentions="" data-lia-user-uid="789997" data-lia-user-login="BhavinVyas3003" class="lia-mention lia-mention-user"&gt;BhavinVyas3003&lt;/a&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Thanks for your prompt response&lt;BR /&gt;&lt;a href="javascript:void(0)" data-lia-user-mentions="" data-lia-user-uid="1282779" data-lia-user-login="ThucLe" class="lia-mention lia-mention-user"&gt;ThucLe&lt;/a&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;You must include Encrypt=yes;TrustServerCertificate=no; in your connection string. Without those, the ODBC driver silently fails during the Azure AD auth handshake, resulting in a timeout.&lt;/P&gt;
&lt;P&gt;import pyodbc&lt;/P&gt;
&lt;P&gt;TENANT_ID = "&amp;lt;tenant-id&amp;gt;"&lt;BR /&gt;CLIENT_ID = "&amp;lt;client-id&amp;gt;"&lt;BR /&gt;CLIENT_SECRET = "&amp;lt;client-secret&amp;gt;"&lt;/P&gt;
&lt;P&gt;server = "&amp;lt;lakehouse-name&amp;gt;.datawarehouse.fabric.microsoft.com"&lt;BR /&gt;database = "&amp;lt;your-database-name&amp;gt;"&lt;BR /&gt;username = CLIENT_ID&lt;BR /&gt;password = CLIENT_SECRET&lt;/P&gt;
&lt;P&gt;connection_string = (&lt;BR /&gt;"Driver={ODBC Driver 18 for SQL Server};"&lt;BR /&gt;f"Server={server};"&lt;BR /&gt;f"Database={database};"&lt;BR /&gt;"Authentication=ActiveDirectoryServicePrincipal;"&lt;BR /&gt;f"UID={username};"&lt;BR /&gt;f"PWD={password};"&lt;BR /&gt;"Encrypt=yes;"&lt;BR /&gt;"TrustServerCertificate=no;"&lt;BR /&gt;"ConnectRetryCount=4;"&lt;BR /&gt;)&lt;/P&gt;
&lt;P&gt;print("Attempting connection...")&lt;BR /&gt;conn = pyodbc.connect(connection_string, timeout=30)&lt;/P&gt;
&lt;P&gt;cursor = conn.cursor()&lt;BR /&gt;cursor.execute("SELECT * FROM sys.tables")&lt;BR /&gt;rows = cursor.fetchall()&lt;BR /&gt;for row in rows:&lt;BR /&gt;print(row)&lt;/P&gt;
&lt;P&gt;conn.close()&lt;/P&gt;
&lt;P&gt;Additional Notes:&lt;BR /&gt;Make sure ODBC Driver 18 is installed.&lt;/P&gt;
&lt;P&gt;Double-check that the Lakehouse SQL endpoint is correct.&lt;/P&gt;
&lt;P&gt;You don't need to explicitly specify the TenantId in the connection string — Authentication=ActiveDirectoryServicePrincipal handles that based on the domain.&lt;/P&gt;
&lt;P&gt;&lt;A href="https://learn.microsoft.com/en-us/sql/connect/odbc/using-azure-active-directory?view=sql-server-ver17" target="_blank"&gt;Using Microsoft Entra ID with the ODBC Driver - ODBC Driver for SQL Server | Microsoft Learn&lt;/A&gt;&lt;/P&gt;
&lt;P&gt;&lt;A href="https://learn.microsoft.com/en-us/sql/connect/python/pyodbc/python-sql-driver-pyodbc?view=sql-server-ver17" target="_blank"&gt;Python SQL Driver - pyodbc - Python driver for SQL Server | Microsoft Learn&lt;/A&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;/P&gt;
&lt;P&gt;If this post helped resolve your issue, please consider giving it &lt;STRONG&gt;Kudos&lt;/STRONG&gt; and marking it as the &lt;STRONG&gt;Accepted Solution&lt;/STRONG&gt;. This not only acknowledges the support provided but also helps other community members find relevant solutions more easily.&lt;/P&gt;
&lt;P&gt;We appreciate your engagement and thank you for being an active part of the community.&lt;/P&gt;
&lt;P&gt;&lt;STRONG&gt;Best regards,&lt;BR /&gt;LakshmiNarayana&lt;/STRONG&gt;.&lt;/P&gt;</description>
      <pubDate>Fri, 30 May 2025 09:49:07 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/Data-Warehouse/pyodbc-login-timeout-expired-when-connecting-to-Lakehouse-SQL/m-p/4713778#M3119</guid>
      <dc:creator>v-lgarikapat</dc:creator>
      <dc:date>2025-05-30T09:49:07Z</dc:date>
    </item>
    <item>
      <title>Re: pyodbc login timeout expired when connecting to Lakehouse SQL endpoint using Service Principal</title>
      <link>https://community.fabric.microsoft.com/t5/Data-Warehouse/pyodbc-login-timeout-expired-when-connecting-to-Lakehouse-SQL/m-p/4716328#M3136</link>
      <description>&lt;P&gt;Hi&amp;nbsp;&lt;a href="javascript:void(0)" data-lia-user-mentions="" data-lia-user-uid="1282779" data-lia-user-login="ThucLe" class="lia-mention lia-mention-user"&gt;ThucLe&lt;/a&gt;&amp;nbsp;,&lt;/P&gt;
&lt;P&gt;If your issue has been resolved, please consider marking the most helpful reply as the &lt;STRONG&gt;accepted solution&lt;/STRONG&gt;. This helps other community members who may encounter the same issue to find answers more efficiently.&lt;/P&gt;
&lt;P&gt;If you're still facing challenges, feel free to let us know we’ll be glad to assist you further.&lt;/P&gt;
&lt;P&gt;Looking forward to your response.&lt;/P&gt;
&lt;P&gt;&lt;STRONG&gt;Best regards,&lt;/STRONG&gt;&lt;BR /&gt;&lt;STRONG&gt;LakshmiNarayana.&lt;/STRONG&gt;&lt;/P&gt;</description>
      <pubDate>Mon, 02 Jun 2025 07:22:42 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/Data-Warehouse/pyodbc-login-timeout-expired-when-connecting-to-Lakehouse-SQL/m-p/4716328#M3136</guid>
      <dc:creator>v-lgarikapat</dc:creator>
      <dc:date>2025-06-02T07:22:42Z</dc:date>
    </item>
    <item>
      <title>Re: pyodbc login timeout expired when connecting to Lakehouse SQL endpoint using Service Principal</title>
      <link>https://community.fabric.microsoft.com/t5/Data-Warehouse/pyodbc-login-timeout-expired-when-connecting-to-Lakehouse-SQL/m-p/4720608#M3165</link>
      <description>&lt;P&gt;Hi&amp;nbsp;&lt;a href="javascript:void(0)" data-lia-user-mentions="" data-lia-user-uid="1282779" data-lia-user-login="ThucLe" class="lia-mention lia-mention-user"&gt;ThucLe&lt;/a&gt;&amp;nbsp;,&lt;/P&gt;
&lt;P&gt;If your question has been answered, kindly mark the appropriate response as the Accepted Solution. This small step goes a long way in helping others with similar issues.&lt;/P&gt;
&lt;P&gt;We appreciate your collaboration and support!&lt;/P&gt;
&lt;P&gt;&lt;STRONG&gt;Best regards,&lt;/STRONG&gt;&lt;BR /&gt;&lt;STRONG&gt;LakshmiNarayana&lt;/STRONG&gt;&lt;/P&gt;</description>
      <pubDate>Thu, 05 Jun 2025 04:48:39 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/Data-Warehouse/pyodbc-login-timeout-expired-when-connecting-to-Lakehouse-SQL/m-p/4720608#M3165</guid>
      <dc:creator>v-lgarikapat</dc:creator>
      <dc:date>2025-06-05T04:48:39Z</dc:date>
    </item>
    <item>
      <title>Re: pyodbc login timeout expired when connecting to Lakehouse SQL endpoint using Service Principal</title>
      <link>https://community.fabric.microsoft.com/t5/Data-Warehouse/pyodbc-login-timeout-expired-when-connecting-to-Lakehouse-SQL/m-p/5145502#M4445</link>
      <description>&lt;P&gt;Hi&amp;nbsp;&lt;a href="javascript:void(0)" data-lia-user-mentions="" data-lia-user-uid="1271221" data-lia-user-login="v-lgarikapat" class="lia-mention lia-mention-user"&gt;v-lgarikapat&lt;/a&gt;&amp;nbsp;&lt;BR /&gt;&lt;BR /&gt;You said:&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;You must include Encrypt=yes;TrustServerCertificate=no; in your connection string. Without those, the ODBC driver silently fails during the Azure AD auth handshake, resulting in a timeout.&lt;/STRONG&gt;&lt;BR /&gt;&lt;BR /&gt;Is this still true now (about a year later)?&lt;BR /&gt;&lt;BR /&gt;I'm also having timeout messages when trying to connect, and it seems possible that your suggestion is the reason for the problems.&lt;BR /&gt;&lt;BR /&gt;Your explanation sounds so crazy, that I am starting to think it might be true.&amp;nbsp;&amp;nbsp;Can you share any documentation about this silent suppression of auth failures?&amp;nbsp; How did you learn about it?&amp;nbsp; Can you please share a source?&amp;nbsp; I will probably open a support ticket with CSS-pro at Mindtree.&amp;nbsp; Do you have a prior SR# or ICM# that can be used as a reference?&amp;nbsp; The MT engineers will probably have a hard time believing your explanation without some sort of corroboration.&lt;/P&gt;</description>
      <pubDate>Thu, 09 Apr 2026 00:48:11 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/Data-Warehouse/pyodbc-login-timeout-expired-when-connecting-to-Lakehouse-SQL/m-p/5145502#M4445</guid>
      <dc:creator>dbeavon3</dc:creator>
      <dc:date>2026-04-09T00:48:11Z</dc:date>
    </item>
    <item>
      <title>Re: pyodbc login timeout expired when connecting to Lakehouse SQL endpoint using Service Principal</title>
      <link>https://community.fabric.microsoft.com/t5/Data-Warehouse/pyodbc-login-timeout-expired-when-connecting-to-Lakehouse-SQL/m-p/5146024#M4447</link>
      <description>&lt;P&gt;Hi&amp;nbsp;&lt;a href="javascript:void(0)" data-lia-user-mentions="" data-lia-user-uid="120263" data-lia-user-login="dbeavon3" class="lia-mention lia-mention-user"&gt;dbeavon3&lt;/a&gt;&amp;nbsp;,&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Thanks for reaching out to the Fabric forum. Since this thread has already been marked as solved, could you please create a new thread that covers your specific use cases along with sample details? This will help us address your follow‑up questions more effectively&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Thanks,&lt;/P&gt;
&lt;P&gt;Lakshmi.&lt;/P&gt;</description>
      <pubDate>Thu, 09 Apr 2026 15:40:04 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/Data-Warehouse/pyodbc-login-timeout-expired-when-connecting-to-Lakehouse-SQL/m-p/5146024#M4447</guid>
      <dc:creator>v-lgarikapat</dc:creator>
      <dc:date>2026-04-09T15:40:04Z</dc:date>
    </item>
  </channel>
</rss>

