You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: articles/app-service/includes/tutorial-connect-msi-azure-database/code-sql-mi.md
+6-7Lines changed: 6 additions & 7 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -79,28 +79,27 @@ For more information, see [Connect using Microsoft Entra authentication](/sql/co
79
79
80
80
1. Install dependencies.
81
81
```bash
82
-
python -m pip install pyodbc
82
+
python -m pip install mssql-python python-dotenv
83
83
```
84
84
85
85
1. Get the Azure SQL Database connection configurations from the environment variable added by Service Connector. Uncomment the part of the code snippet for the authentication type you want to use.
86
86
```python
87
-
import os;
88
-
import pyodbc
87
+
import os
88
+
from mssql_python import connect
89
89
90
90
server = os.getenv('AZURE_SQL_SERVER')
91
91
port = os.getenv('AZURE_SQL_PORT')
92
92
database = os.getenv('AZURE_SQL_DATABASE')
93
-
authentication = os.getenv('AZURE_SQL_AUTHENTICATION') # The value should be 'ActiveDirectoryMsi'
94
93
95
94
# Uncomment the following lines according to the authentication type.
96
95
# For system-assigned managed identity.
97
-
#connString = f'Driver={{ODBC Driver 18 for SQL Server}};Server={server},{port};Database={database};Authentication={authentication};Encrypt=yes;'
For an alternative method, you can also connect to Azure SQL Database using an access token, refer to [Migrate a Python application to use passwordless connections with Azure SQL Database](/azure/azure-sql/database/azure-sql-passwordless-migration-python).
Copy file name to clipboardExpand all lines: articles/azure-functions/recover-python-functions.md
+4-1Lines changed: 4 additions & 1 deletion
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -235,7 +235,10 @@ If your function app is using the Python pickle library to load a Python object
235
235
236
236
### Pyodbc connection collision
237
237
238
-
If your function app is using the popular ODBC database driver [pyodbc](https://github.com/mkleehammer/pyodbc), it's possible that multiple connections are open within a single function app. To avoid this issue, use the singleton pattern, and ensure that only one pyodbc connection is used across the function app.
238
+
If your function app is using the ODBC database driver [pyodbc](https://github.com/mkleehammer/pyodbc), it's possible that multiple connections are open within a single function app. To avoid this issue, use the singleton pattern, and ensure that only one pyodbc connection is used across the function app.
239
+
240
+
> [!TIP]
241
+
> Consider using [mssql-python](https://github.com/microsoft/mssql-python), Microsoft's official Python driver for SQL Server, which provides built-in Microsoft Entra authentication support and doesn't require manual ODBC driver management.
Copy file name to clipboardExpand all lines: articles/service-connector/includes/code-fabricsql-me-id.md
+7-8Lines changed: 7 additions & 8 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -88,25 +88,24 @@ spring:
88
88
89
89
1. Install dependencies.
90
90
```bash
91
-
python -m pip install pyodbc
91
+
python -m pip install mssql-python python-dotenv
92
92
```
93
93
94
-
1. Retrieve the SQL database in Microsoft Fabric connection string from the environment variable added by Service Connector. If you are using Azure Container Apps as compute service or the connection string in the code snippet doesn't work, refer to [Migrate a Python application to use passwordless connections with Azure SQL Database](/azure/azure-sql/database/azure-sql-passwordless-migration-python#update-the-local-connection-configuration) to connect to SQL database in Microsoft Fabric using passwordless credentials. `Authentication=ActiveDirectoryMSI;` is required in the connection string when connecting using managed identities. `UID=<msiClientId>` is also required in the connection string when connecting using a user-assigned managed identity.
94
+
1. Retrieve the SQL database in Microsoft Fabric connection string from the environment variable added by Service Connector. `Authentication=ActiveDirectoryMSI;` is required in the connection string when connecting using managed identities. `UID=<msiClientId>` is also required in the connection string when connecting using a user-assigned managed identity.
Copy file name to clipboardExpand all lines: articles/service-connector/includes/code-sql-me-id.md
+8-9Lines changed: 8 additions & 9 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -82,34 +82,33 @@ Update your application following the tutorial [Migrate a Java application to us
82
82
83
83
1. Install dependencies.
84
84
```bash
85
-
python -m pip install pyodbc
85
+
python -m pip install mssql-python python-dotenv
86
86
```
87
87
88
-
1. Get the Azure SQL Database connection configurations from the environment variable added by Service Connector. When using the code below, uncomment the part of the code snippet forthe authentication type you want to use. If you are using Azure Container Apps as compute service or the connection stringin the code snippet doesn't work, refer to [Migrate a Python application to use passwordless connections with Azure SQL Database](/azure/azure-sql/database/azure-sql-passwordless-migration-python) to connect to Azure SQL Database using an access token.
88
+
1. Get the Azure SQL Database connection configurations from the environment variable added by Service Connector. When using the code below, uncomment the part of the code snippet for the authentication type you want to use.
0 commit comments