python-tds
Python DBAPI driver for MSSQL using pure Python TDS (Tabular Data Stream) protocol implementation
What it is and what it does
python-tds is a pure Python DBAPI driver for Microsoft SQL Server that implements the TDS (Tabular Data Stream) protocol directly, without depending on external libraries like ADO or FreeTDS. This makes it portable across Linux, macOS, and Windows. It follows the Python DBAPI standard, so it integrates with standard database tooling and ORMs like django-sqlserver.
The driver supports MSSQL 2008 date types (datetime2, date, time, datetimeoffset), MARS, bulk insert, table-valued parameters, TLS encryption, and token-based authentication. Optional packages can extend functionality for TLS, performance, and Kerberos support on non-Windows platforms. Connection uses standard cursor operations after calling connect() with credentials or a token callable.
Use it for:
- Connect to MSSQL databases from Python on Linux or macOS without installing FreeTDS or ADO.
- Use as a Django database backend via django-sqlserver for MSSQL-backed Django projects.
- Implement token-based authentication to Azure SQL Database using access token callables.
- Perform bulk inserts or use table-valued parameters for high-performance data operations.
- Establish encrypted TLS connections to MSSQL servers by providing a CA certificate file.
Worth the install?
AI-flagged interpretation of the facts on this page — verify before relying
Pure Python DBAPI driver for MSSQL that implements the TDS protocol without requiring ADO or FreeTDS, enabling database connections on any platform.
Yes. This is a mature, actively maintained driver with no known vulnerabilities, low install friction, and permissive licensing. It fills a genuine need for pure-Python MSSQL connectivity on non-Windows platforms. Install it if you need to connect to MSSQL from Python without external system dependencies.
Install
python-tds on PyPI
pip
pip install python-tdsuv
uv add python-tdspoetry
poetry add python-tdsInstalling python-tds
Before you install
Low friction installation with no runtime dependencies. Actively maintained as of 2026-08-07 with recent release history.
License in practice
MIT license permits unrestricted use, modification, and distribution in both open and closed-source projects.
Quickstart
pip install python-tds
Connection example from documentation:
with connect('server', 'database', 'user', 'password') as conn:
with conn.cursor() as cur:
cur.execute("select 1")
cur.fetchall()
Verify before relying
- Whether Kerberos support on non-Windows platforms is production-ready given the 'experimental' label in the description.
- Performance characteristics compared to other MSSQL drivers in typical workloads.
- Compatibility with specific MSSQL versions beyond the 2008 date types mentioned.
- Whether optional packages (pyOpenSSL, bitarray, kerberos) are required or truly optional for core functionality.
Package facts
| License | MIT (permissive) |
| Python support | not specified |
| Install friction | low — pure-Python wheel |
| Runtime dependencies | none |
| Maintenance | actively maintained — 335 days since the last release |
| Last repo commit | |
| First released | |
| Downloads | 4,254,407/month — #2,348 on PyPI (30-day window, as of 2026-08-14) |
| Known vulnerabilities | none known (OSV.dev, checked 2026-08-14) |
Evidence: python_tds-1.17.1-py3-none-any.whl
Tags
More Database packages
psycopg2-binary is a PostgreSQL database…
copyleft · top 1,000 on PyPI
redisPython client library for connecting to and…
permissive · top 1,000 on PyPI
ydbYDB Python SDK is the official client library…
permissive · top 1,000 on PyPI
snowflake-connector-pythonConnects Python applications to Snowflake data…
permissive · top 1,000 on PyPI
sqlparsesqlparse tokenizes SQL text into a tree of…
permissive · top 1,000 on PyPI
dbt-adaptersProvides base adapter protocols and shared…
permissive · top 1,000 on PyPI
sqlalchemy-pytdsProvides a SQLAlchemy dialect for connecting to…
permissive · top 5,000 on PyPI
pymssqlpymssql provides a Python DB-API interface to…
copyleft · top 1,000 on PyPI
mssql-djangoDjango database backend that connects Django…
permissive · top 15,000 on PyPI
mssql-pythonA Python driver for connecting to and querying…
unclear · top 5,000 on PyPI
pyadomdPyadomd provides a Python interface to query…
permissive · top 15,000 on PyPI
pymonetdbpymonetdb is a native Python client library for…
copyleft · top 15,000 on PyPI
mssqlWraps SQLAlchemy and pyodbc to simplify…
permissive · top 15,000 on PyPI
presto-python-clientProvides a Python DBAPI-compatible client to…
permissive · top 5,000 on PyPI
bcpandasWraps SQL Server's BCP utility to transfer data…
permissive · top 15,000 on PyPI
adbc-driver-sqliteProvides a DBAPI 2.0-compatible Python…
permissive · top 5,000 on PyPI