mssql-django
Django backend for Microsoft SQL Server
What it is and what it does
mssql-django is the official Microsoft-supported Django database backend for SQL Server and Azure SQL. It replaces Django's default backend with one that speaks SQL Server's dialect, allowing you to define Django models and run queries against SQL Server 2016–2025, Azure SQL Database, Managed Instance, and SQL Database in Microsoft Fabric. The package wraps pyodbc (a Python ODBC library) and handles the translation between Django's ORM and SQL Server's T-SQL, including transaction management, connection pooling via pyodbc, and timezone handling via pytz.
Installation is straightforward—pip pulls in django, pyodbc, and pytz automatically—and configuration happens in Django's settings.py by setting ENGINE to 'mssql' and providing connection details (HOST, USER, PASSWORD, etc.). The backend supports Django 3.2, 4.0, 4.1, 4.2, 5.0, 5.1, 5.2, 6.0, 6.1 and Python 3.8–3.14, though Django 6.0 and 6.1 require Python 3.12+. It includes known limitations around certain field migrations, JSONField operations, and some advanced query patterns, documented in the project's wiki.
Use it for:
- Migrate an existing Django application from SQLite or PostgreSQL to SQL Server or Azure SQL without rewriting models or queries.
- Build a new Django web application targeting Azure SQL Database or SQL Database in Microsoft Fabric as the primary data store.
- Connect Django to an on-premises SQL Server 2019 or 2022 instance in an enterprise environment.
- Use Azure AD authentication with Django by configuring TOKEN-based or extra_params-based connection options.
- Run Django tests against a SQL Server test database with custom collation or creation-order dependencies.
Worth the install?
AI-flagged interpretation of the facts on this page — verify before relying
Django database backend that connects Django applications to Microsoft SQL Server, Azure SQL, and SQL Database in Microsoft Fabric via pyodbc and ODBC drivers.
Yes. This is the official Microsoft-backed backend for SQL Server and Azure SQL, actively maintained with no known vulnerabilities, low install friction, and permissive licensing. Install it if you need Django to connect to SQL Server, Azure SQL, or Microsoft Fabric SQL Database. Be aware of documented limitations around certain field migrations, JSONField operations, and advanced query patterns—review the known limitations table if your application uses those features heavily.
Install
mssql-django on PyPI
pip
pip install mssql-djangouv
uv add mssql-djangopoetry
poetry add mssql-djangoInstalling mssql-django
Before you install
Low friction: pure Python wheel with three runtime dependencies (django, pyodbc, pytz). Actively maintained with a release 7 days ago and recent commits; 399 repository stars indicate established use.
License in practice
BSD permissive license allows commercial and private use with minimal restrictions; suitable for most production deployments.
Quickstart
pip install mssql-django
# In settings.py:
DATABASES = {
'default': {
'ENGINE': 'mssql',
'NAME': 'mydb',
'USER': 'user@myserver',
'PASSWORD': 'password',
'HOST': 'myserver.database.windows.net',
'PORT': '',
'OPTIONS': {
'driver': 'ODBC Driver 18 for SQL Server',
},
},
}
Microsoft ODBC Driver 17 or 18 for SQL Server must be installed on the system; FreeTDS ODBC driver is also supported as an alternative.
Verify before relying
- Exact scope of JSONField lookup limitations and whether they affect common query patterns
- Whether the listed known limitations (e.g., AutoField migration, floating-point arithmetic) materially impact typical Django applications
- Performance characteristics and connection pooling behavior under high concurrency
Package facts
| License | BSD (permissive) |
| Python support | not specified |
| Install friction | low — pure-Python wheel |
| Runtime dependencies | 3 — django, pyodbc, pytz |
| Maintenance | actively maintained — 7 days since the last release |
| Last repo commit | |
| First released | |
| Downloads | 463,781/month — #6,519 on PyPI (30-day window, as of 2026-08-14) |
| Known vulnerabilities | none known (OSV.dev, checked 2026-08-14) |
Evidence: mssql_django-1.8.0-py3-none-any.whl
Keywords: django
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
mssql-pythonA Python driver for connecting to and querying…
unclear · top 5,000 on PyPI
mssqlWraps SQLAlchemy and pyodbc to simplify…
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
django-snowflakeProvides a Django database backend that…
permissive · top 15,000 on PyPI
pyodbcpyodbc provides Python access to ODBC databases…
permissive · top 1,000 on PyPI
python-tdsPure Python DBAPI driver for MSSQL that…
permissive · top 5,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
dbt-sqlserverA dbt adapter that enables data transformation…
permissive · top 15,000 on PyPI