How microsoft/mssql-python works
mssql-python is a Python DB-API 2.0 driver for SQL Server and Azure SQL, using DDBC for direct native connections. The main workflow is an application creating a connection, parsing connection settings and authenticating, executing statements through cursors, and fetching Python rows from SQL Server. The graph also preserves the documented async API and opt-in native-provider selection. Native binding internals are represented at their implementation paths; some links rely on README or source-index references because the relevant source was not excerpted.
Main entry points: connection.py Connection lifecycle · cursor.py Query and fetch · async_cursor.py Async cursor · ddbc_bindings.py Binding loader
Components 19
Python driver API
- DB-API exports
mssql_python/__init__.py - Connection lifecycle
mssql_python/connection.py - Query and fetch
mssql_python/cursor.py - Row results
mssql_python/row.py
Connection setup
- Connection parsing
mssql_python/connection_string_parser.py - Connection building
mssql_python/connection_string_builder.py - Entra authentication
mssql_python/auth.py - Connection pooling
mssql_python/pooling.py - ODBC provider selection
mssql_python/odbc_provider.py
Native execution
- Binding loader
mssql_python/ddbc_bindings.py - Native DDBC bindings
mssql_python/pybind/ddbc_bindings.cpp - Native connection
mssql_python/pybind/connection/connection.cpp
Async and providers
- Async connection
mssql_python/async_query/async_connection.py - Async cursor
mssql_python/async_query/async_cursor.py - Async execution
mssql_python/async_query/async_execute.py - Async fetching
mssql_python/async_query/async_fetch.py - Rust ODBC provider
Other components
- Python application
- SQL Server / Azure SQL
Connections 19
- Python application → DB-API exports: uses
README.md - DB-API exports → Connection lifecycle: creates
mssql_python/__init__.py - Connection lifecycle → Connection parsing: parses
mssql_python/connection.py - Connection lifecycle → Connection building: builds
mssql_python/connection.py - Connection lifecycle → Entra authentication: authenticates
mssql_python/connection.py - Connection lifecycle → Connection pooling: uses
mssql_python/connection.py - Connection lifecycle → ODBC provider selection: selects
README.md - Connection lifecycle → Query and fetch: creates
mssql_python/connection.py - Query and fetch → Row results: returns
mssql_python/cursor.py - Connection lifecycle → Binding loader: calls
mssql_python/connection.py - Query and fetch → Binding loader: calls
mssql_python/cursor.py - Binding loader → Native DDBC bindings: loads
README.md - Native DDBC bindings → Native connection: uses
mssql_python/pybind/ddbc_bindings.cpp - Native connection → SQL Server / Azure SQL: connects
README.md - Python application → Async connection: uses
README.md - Async connection → Async cursor: creates
mssql_python/async_query/async_connection.py - Async cursor → Async execution: delegates
mssql_python/async_query/async_cursor.py - Async cursor → Async fetching: delegates
mssql_python/async_query/async_cursor.py - ODBC provider selection → Rust ODBC provider: selects optionally
README.md