skillfed

python-tds

Python DBAPI driver for MSSQL using pure Python TDS (Tabular Data Stream) protocol implementation

python-tds v1.17.1 4.3M downloads/30d#2,348 on PyPI218
Permissive license MIT Active released

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-tds

uv

uv add python-tds

poetry

poetry add python-tds

Installing 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

Development Status :: 4 - BetaProgramming Language :: PythonProgramming Language :: Python :: 3.10Programming Language :: Python :: 3.11Programming Language :: Python :: 3.12Programming Language :: Python :: 3.8Programming Language :: Python :: 3.9

Tags

mssql python drivertds protocol clientsql server connectionpure python database driverdbapi mssqlcross-platform sql servertds tabular data stream
mssqldbapitds-protocol

More Database packages