@@ -206,11 +206,13 @@ def _initialize_(self):
206206 passwd = self .credential_decoder (password ),
207207 )
208208
209- #Added support for Pymssql
209+
210+ # Added support for Pymssql
210211@adapters .register_for ("pymssql" )
211212class PyMssql (MSSQL ):
212213 def _initialize_ (self ):
213- import pymssql
214+ import pymssql
215+
214216 self .driver = pymssql
215217 super (MSSQL , self )._initialize_ ()
216218 ruri = self .uri .split ("://" , 1 )[1 ]
@@ -240,13 +242,13 @@ def connector(self):
240242class MSSQLPython (MSSQL4 ):
241243 """
242244 MSSQL adapter for Microsoft's official mssql-python driver.
243-
245+
244246 Supports SQL Server 2012+ with modern OFFSET/FETCH pagination.
245247 Features encryption-by-default and Microsoft Entra ID authentication.
246-
248+
247249 URI format:
248250 mssqlpython://user:password@server:port/database?param=value
249-
251+
250252 Supported URI parameters:
251253 - encrypt: Enable encryption (default: yes, values: yes/no/true/false/1/0)
252254 - trust_server_certificate: Trust self-signed certificates (default: no)
@@ -258,22 +260,25 @@ class MSSQLPython(MSSQL4):
258260 * ActiveDirectoryIntegrated: Integrated Windows Auth/Kerberos
259261 * ActiveDirectoryDefault: Default authentication based on environment
260262 * ActiveDirectoryDeviceCode: Device code flow authentication
261-
263+
262264 Example URIs:
263265 # Standard SQL authentication with encryption
264266 mssqlpython://user:pass@server.database.windows.net:1433/mydb
265-
267+
266268 # Entra ID Interactive authentication
267269 mssqlpython://user@server.database.windows.net/mydb?authentication=ActiveDirectoryInteractive
268-
270+
269271 # Managed Identity (no user/password needed)
270272 mssqlpython://@server.database.windows.net/mydb?authentication=ActiveDirectoryMSI
271-
273+
272274 # Disable encryption (for testing/legacy)
273275 mssqlpython://user:pass@localhost:1433/mydb?encrypt=no&trust_server_certificate=yes
274276 """
275- drivers = ("mssql-python" ,) # Note: URI scheme is mssqlpython://, driver name is mssql-python
276-
277+
278+ drivers = (
279+ "mssql-python" ,
280+ ) # Note: URI scheme is mssqlpython://, driver name is mssql-python
281+
277282 # Override REGEX_URI to make user optional for Managed Identity scenarios
278283 REGEX_URI = (
279284 r"^(?P<user>[^:@]*)(:(?P<password>[^@]*))?"
@@ -284,6 +289,7 @@ class MSSQLPython(MSSQL4):
284289
285290 def _initialize_ (self ):
286291 import mssql_python
292+
287293 self .driver = mssql_python
288294 # Skip MSSQL._initialize_() and call grandparent to avoid base MSSQL's REGEX
289295 super (MSSQL , self )._initialize_ ()
@@ -298,15 +304,17 @@ def _initialize_(self):
298304
299305 # Extract basic connection parameters
300306 user = self .credential_decoder (m .group ("user" )) if m .group ("user" ) else ""
301- password = self .credential_decoder (m .group ("password" )) if m .group ("password" ) else ""
302-
307+ password = (
308+ self .credential_decoder (m .group ("password" )) if m .group ("password" ) else ""
309+ )
310+
303311 # Build driver connection arguments
304312 self .driver_args .update (
305313 server = m .group ("host" ),
306314 database = m .group ("db" ),
307315 port = int (m .group ("port" ) or "1433" ),
308316 )
309-
317+
310318 # Add credentials if provided (not required for some Entra ID auth modes)
311319 if user :
312320 self .driver_args ["user" ] = user
@@ -315,7 +323,7 @@ def _initialize_(self):
315323
316324 # Handle authentication parameter
317325 # Supported modes: ActiveDirectoryPassword, ActiveDirectoryInteractive,
318- # ActiveDirectoryMSI, ActiveDirectoryServicePrincipal,
326+ # ActiveDirectoryMSI, ActiveDirectoryServicePrincipal,
319327 # ActiveDirectoryIntegrated, ActiveDirectoryDefault, ActiveDirectoryDeviceCode
320328 if "authentication" in uri_args :
321329 self .driver_args ["authentication" ] = uri_args ["authentication" ]
@@ -345,4 +353,4 @@ def _initialize_(self):
345353 self .driver_args [key ] = value
346354
347355 def connector (self ):
348- return self .driver .connect (** self .driver_args )
356+ return self .driver .connect (** self .driver_args )
0 commit comments