Skip to content

Commit dd78d19

Browse files
committed
fixsql
1 parent 749582a commit dd78d19

File tree

1 file changed

+14
-18
lines changed

1 file changed

+14
-18
lines changed

articles/service-connector/includes/code-sql-me-id.md

Lines changed: 14 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -87,26 +87,26 @@ Update your application following the tutorial [Migrate a Java application to us
8787
8888
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.
8989
```python
90-
import os;
90+
import os
9191
import pyodbc
9292
9393
server = os.getenv('AZURE_SQL_SERVER')
9494
port = os.getenv('AZURE_SQL_PORT')
9595
database = os.getenv('AZURE_SQL_DATABASE')
9696
authentication = os.getenv('AZURE_SQL_AUTHENTICATION')
9797
98-
# Uncomment the following lines according to the authentication type.
98+
# Uncomment the following lines according to the authentication type. Customize the driver version as you want.
9999
# For system-assigned managed identity.
100-
# connString = f'Driver={{ODBC Driver 18 for SQL Server}};Server={server},{port};Database={database};Authentication={authentication};Encrypt=yes;'
100+
# connString = f'Driver={{ODBC Driver 17 for SQL Server}};Server={server},{port};Database={database};Authentication={authentication};Encrypt=yes;TrustServerCertificate=no;Connection Timeout=30'
101101
102102
# For user-assigned managed identity.
103103
# user = os.getenv('AZURE_SQL_USER')
104-
# connString = f'Driver={{ODBC Driver 18 for SQL Server}};Server={server},{port};Database={database};UID={user};Authentication={authentication};Encrypt=yes;'
104+
# connString = f'Driver={{ODBC Driver 17 for SQL Server}};Server={server},{port};Database={database};UID={user};Authentication={authentication};Encrypt=yes;TrustServerCertificate=no;Connection Timeout=30'
105105
106106
# For service principal.
107107
# user = os.getenv('AZURE_SQL_USER')
108108
# password = os.getenv('AZURE_SQL_PASSWORD')
109-
# connString = f'Driver={{ODBC Driver 18 for SQL Server}};Server={server},{port};Database={database};UID={user};PWD={password};Authentication={authentication};Encrypt=yes;'
109+
# connString = f'Driver={{ODBC Driver 18 for SQL Server}};Server=tcp:{server},{port};Database={database};UID={user};PWD={password};Authentication={authentication};Encrypt=yes;TrustServerCertificate=no;Connection Timeout=30'
110110
111111
conn = pyodbc.connect(connString)
112112
```
@@ -133,7 +133,7 @@ Update your application following the tutorial [Migrate a Java application to us
133133
// port,
134134
// database,
135135
// authentication: {
136-
// authenticationType
136+
// type: authenticationType
137137
// },
138138
// options: {
139139
// encrypt: true
@@ -147,13 +147,11 @@ Update your application following the tutorial [Migrate a Java application to us
147147
// port,
148148
// database,
149149
// authentication: {
150-
// type: authenticationType,
151-
// options: {
152-
// clientId: clientId
153-
// }
150+
// type: authenticationType
154151
// },
155152
// options: {
156-
// encrypt: true
153+
// encrypt: true,
154+
// clientId: clientId
157155
// }
158156
// };
159157
@@ -166,15 +164,13 @@ Update your application following the tutorial [Migrate a Java application to us
166164
// port,
167165
// database,
168166
// authentication: {
169-
// type: authenticationType,
170-
// options: {
171-
// clientId: clientId,
172-
// clientSecret: clientSecret,
173-
// tenantId: tenantId
174-
// }
167+
// type: authenticationType
175168
// },
176169
// options: {
177-
// encrypt: true
170+
// encrypt: true,
171+
// clientId: clientId,
172+
// clientSecret: clientSecret,
173+
// tenantId: tenantId
178174
// }
179175
// };
180176

0 commit comments

Comments
 (0)