Forum Discussion
Using pyodbc in python 3.11 notebook
- 10 months ago
Hi P_work ,
Thanks for the follow up.
As Vinodh247 already mentioned, keeping long running global connections is not recommended because the SQL analytics endpoint can become idle and drop sessions in the background. The Microsoft documentation notes that the endpoint can be suspended after inactivity:
https://learn.microsoft.com/en-us/fabric/data-warehouse/sql-analytics-endpoint-performanceIn that case a reused pyodbc connection may fail since pyodbc does not automatically recover when the backend session is dropped.
There are similar reports in the community where idle connections to the lakehouse SQL endpoint resulted in errors:
Solved: Failed to access/connect to Lakehouse SQL Endpoint... - Microsoft Fabric CommunityTo reduce repeated reconnect times you can keep related queries inside the same connection block and optionally add a simple retry approach for transient disconnects.
Hope this helps. Please reach out for further assistance.
Thank you.
One issue when not using global connections is that SQL Analytics Endpoint appears to require upwards of four seconds to connect. Any specifics regarding dropping of idle sessions? i.e. Opening a global connection and have it close when notebook session ends would alleviate this issue.
Hi P_work ,
Thanks for the follow up.
As Vinodh247 already mentioned, keeping long running global connections is not recommended because the SQL analytics endpoint can become idle and drop sessions in the background. The Microsoft documentation notes that the endpoint can be suspended after inactivity:
https://learn.microsoft.com/en-us/fabric/data-warehouse/sql-analytics-endpoint-performance
In that case a reused pyodbc connection may fail since pyodbc does not automatically recover when the backend session is dropped.
There are similar reports in the community where idle connections to the lakehouse SQL endpoint resulted in errors:
Solved: Failed to access/connect to Lakehouse SQL Endpoint... - Microsoft Fabric Community
To reduce repeated reconnect times you can keep related queries inside the same connection block and optionally add a simple retry approach for transient disconnects.
Hope this helps. Please reach out for further assistance.
Thank you.
- v-veshwara-msft9 months ago
Community Support
Hi P_work ,
Just wanted to check if the response provided was helpful. If further assistance is needed, please reach out.
Thank you.