mssql-python
A Python library for interacting with Microsoft SQL Server
What it is and what it does
mssql-python is Microsoft's official Python driver for SQL Server and Azure SQL. It replaces the traditional pyodbc-style architecture with DDBC (Direct Database Connectivity), a lightweight C++ layer that bypasses the platform's driver manager and interfaces directly with native SQL Server drivers. This design eliminates the need to install a separate driver manager on Windows and provides consistent behavior across Windows, macOS, and Linux.
The driver is built with PyBind11 for memory-safe, high-performance bindings. It supports modern authentication via azure-identity (DefaultAzureCredential, ManagedIdentityCredential, and custom token providers), identity-aware connection pooling with automatic token refresh, and bulk operations including a new Arrow-based bulk copy method for high-performance data loading. Recent fixes address parameter binding edge cases, output converter dispatch, and cursor lifecycle management.
Use it for:
- Connect to Azure SQL Database or SQL Server from Python applications without installing external driver managers.
- Bulk-load data from PyArrow tables or RecordBatches using the new bulkcopy_arrow() method for high-throughput ETL.
- Authenticate to SQL Server using Azure managed identities or DefaultAzureCredential from azure-identity.
- Execute parameterized queries with automatic type conversion and memory-safe bindings via PyBind11.
- Use connection pooling with automatic token refresh for long-running applications accessing SQL Server as different Azure identities.
Worth the install?
AI-flagged interpretation of the facts on this page — verify before relying
A Python driver for connecting to and querying Microsoft SQL Server, Azure SQL, and SQL databases in Fabric, using a direct C++ backend (DDBC) instead of platform-specific driver managers.
Yes, with conditions. mssql-python is actively maintained, recently released (7 days ago), and offers a modern alternative to pyodbc with no external driver-manager dependency on Windows. It has no known vulnerabilities and supports current Python versions (3.10–3.12). However, verify the license terms before production use, as the license treatment is currently unclear. If you are building a new SQL Server integration and can target Python ≥3.10, this is a solid choice; if you need legacy Python support or have existing pyodbc code, stick with that.
Install
mssql-python on PyPI
pip
pip install mssql-pythonuv
uv add mssql-pythonpoetry
poetry add mssql-pythonInstalling mssql-python
Before you install
Medium install friction due to compiled wheels for multiple platforms and Python versions (3.10–3.12). Active maintenance with a release 7 days ago. Depends on mssql-python-odbc (hard dependency as of v1.13.0) and azure-identity for token-based auth; on Windows, no external driver manager is required.
License in practice
License treatment is unclear—no SPDX identifier or raw license text is recorded. Before production use, verify the actual license terms on the project repository.
Quickstart
pip install mssql-python
import mssql
conn = mssql.connect(server='localhost', database='mydb', user='sa', password='pass')
cursor = conn.cursor()
cursor.execute('SELECT * FROM table')
for row in cursor.fetchall():
print(row)
Requires Python ≥3.10. mssql-python-odbc is automatically installed as a dependency. On non-Windows platforms, the ODBC driver binaries are included in the mssql-python-odbc package.
Verify before relying
- Exact license terms and any restrictions on commercial or proprietary use
- Performance benchmarks vs. pyodbc or other SQL Server drivers
- Full API surface and support for advanced features (e.g., stored procedures, transactions, connection pooling limits)
Package facts
| License | not declared (unclear) |
| Python support | supports the current Python release (>=3.10) |
| Install friction | medium — platform-specific wheel |
| Runtime dependencies | 2 — azure-identity, mssql-python-odbc |
| Maintenance | actively maintained — 7 days since the last release |
| Last repo commit | |
| First released | |
| Downloads | 2,491,049/month — #3,042 on PyPI (30-day window, as of 2026-08-14) |
| Known vulnerabilities | none known (OSV.dev, checked 2026-08-14) |
Evidence: mssql_python-1.13.0-cp310-cp310-macosx_15_0_universal2.whl; mssql_python-1.13.0-cp310-cp310-manylinux_2_28_aarch64.whl; mssql_python-1.13.0-cp310-cp310-manylinux_2_28_x86_64.whl; mssql_python-1.13.0-cp310-cp310-musllinux_1_2_aarch64.whl; mssql_python-1.13.0-cp310-cp310-musllinux_1_2_x86_64.whl; mssql_python-1.13.0-cp310-cp310-win_amd64.whl; mssql_python-1.13.0-cp311-cp311-macosx_15_0_universal2.whl; mssql_python-1.13.0-cp311-cp311-manylinux_2_28_aarch64.whl; mssql_python-1.13.0-cp311-cp311-manylinux_2_28_x86_64.whl; mssql_python-1.13.0-cp311-cp311-musllinux_1_2_aarch64.whl; mssql_python-1.13.0-cp311-cp311-musllinux_1_2_x86_64.whl; mssql_python-1.13.0-cp311-cp311-win_amd64.whl; mssql_python-1.13.0-cp311-cp311-win_arm64.whl; mssql_python-1.13.0-cp312-cp312-macosx_15_0_universal2.whl; mssql_python-1.13.0-cp312-cp312-manylinux_2_28_aarch64.whl; mssql_python-1.13.0-cp312-cp312-manylinux_2_28_x86_64.whl; mssql_python-1.13.0-cp312-cp312-musllinux_1_2_aarch64.whl; mssql_python-1.13.0-cp312-cp312-musllinux_1_2_x86_64.whl; mssql_python-1.13.0-cp312-cp312-win_amd64.whl; mssql_python-1.13.0-cp312-cp312-win_arm64.whl
Tags
More Front-Ends packages
SQLAlchemy is a Python SQL toolkit and Object…
permissive · top 100 on PyPI
psycopg2-binarypsycopg2-binary is a PostgreSQL database…
copyleft · top 1,000 on PyPI
alembicAlembic generates and manages database schema…
permissive · top 1,000 on PyPI
weaviate-clientA Python client library for connecting to and…
permissive · top 1,000 on PyPI
databricks-sql-connectorA Python client library that connects to…
permissive · top 1,000 on PyPI
psycopgPsycopg 3 is a PostgreSQL database adapter for…
copyleft · top 1,000 on PyPI
mssqlWraps SQLAlchemy and pyodbc to simplify…
permissive · top 15,000 on PyPI
mssql-djangoDjango database backend that connects Django…
permissive · top 15,000 on PyPI
mssql-python-odbcProvides platform-specific Microsoft ODBC…
unclear · top 15,000 on PyPI
pymssqlpymssql provides a Python DB-API interface to…
copyleft · top 1,000 on PyPI
pypyodbcpypyodbc provides a pure Python ODBC interface…
permissive · top 15,000 on PyPI
bcpandasWraps SQL Server's BCP utility to transfer data…
permissive · top 15,000 on PyPI
pyodbcpyodbc provides Python access to ODBC databases…
permissive · top 1,000 on PyPI
teradataProvides Python bindings to execute SQL scripts…
permissive · top 15,000 on PyPI
python-tdsPure Python DBAPI driver for MSSQL that…
permissive · top 5,000 on PyPI
sqlalchemy-pytdsProvides a SQLAlchemy dialect for connecting to…
permissive · top 5,000 on PyPI