skip to navigation
skip to content

ctds 1.7.0

DB API 2.0-compliant Linux driver for SQL Server

cTDS is a full Python DB API-2.0-compliant SQL Server database library for Linux, Windows, and Mac OS X supporting both Python 2 and Python 3.


  • Supports Microsoft SQL Server 2008 and up.
  • Complete DB API-2.0 support.
  • Python 2.6, Python 2.7, Python 3.3, Python 3.4, Python 3.5, and Python 3.6 support.
  • Bulk insert (bcp) support.
  • Written entirely in C.



The full documentation for cTDS can be found here.

Generate documentation using the following:

make doc
# Generated to ./.gh-pages

Documentation is hosted on GitHub Pages. As such, the source code for the documentation pages must be committed to the gh-pages branch in order to update the live documentation.


Local development and testing is supported on Linux-based systems running Docker. Docker containers are used for both running a local instance of SQL Server on Linux and creating containers for each combination of Python and FreeTDS version supported. Only Docker and GNU make are required for running tests locally on Linux or OS X systems.

If desired, local development can be done by installing ctds against the system versions of FreeTDS and Python. Additionally there is a virtualenv target which will download and compile a recent version of FreeTDS and then install ctds into a virtualenv using the local version of FreeTDS.

# Install as a "develop" egg
pip install -e .

# Install tests.
pip install -e .[tests]

# Run tests (requires SQL Server running)
python test

However, given the various supported combinations of FreeTDS and Python, it is easier to create a separate Docker container for each. The matrix of FreeTDS and Python is driven using GNU make.

Development and testing will require an instance of SQL Server on Linux running for validation. A script is provided to start a Docker container running the database and create the login used by the tests.

# Start a docker-based SQL Server instance.
make start-sqlserver

# Run tests as needed ...

# Stop the docker-base SQL Server instance.
make stop-sqlserver


Testing is designed to be relatively seamless using Docker containers and SQL Server on Linux. All test targets will ensure a running database instance docker container exists and is accessible prior to running.

To run the tests against the most recent versions of FreeTDS and Python, use:

make test

To run the tests against an arbitrary version of FreeTDS and Python:

# Python X.Y & FreeTDS Z.ZZ.ZZ
make test_X.Y_Z.ZZ.ZZ

To run tests against all supported versions of FreeTDS and Python and additional linting and metadata checks:

make check
File Type Py Version Uploaded on Size
ctds-1.7.0.tar.gz (md5) Source 2018-01-24 67KB