Django backend for Microsoft SQL Server
Actively maintained. Last release 2 months ago, commits in 10 of the last 26 weeks. A safe choice.
pip install mssql-djangoDjango Backend for Microsoft SQL
mssql-django is the official Microsoft‑supported Django database backend for SQL Server, Azure SQL and SQL Database in Microsoft Fabric.
It provides a reliable, enterprise‑grade database connectivity option for the Django web framework, enabling Python developers to build and run production‑ready applications on Microsoft’s data platform.
This project is the continuation and evolution of earlier community efforts, and it builds on the strong foundation established by django-mssql-backend and its predecessors. mssql-django focuses on long‑term stability, performance, security, and compatibility with both Django and SQL Server.
Supportability
| Component | Supported Versions |
|---|---|
| Django | 5.2, 6.0, 6.1 |
| Python | CPython 3.10 – 3.14 (Django 6.0 and 6.1 require 3.12+) |
| Platforms | Windows x64; Windows ARM64 with Python 3.11+; macOS 15+ on Intel or Apple silicon; Linux x64/ARM64 with glibc 2.28+ or musl 1.2+ |
| SQL Server | 2017, 2019, 2022, 2025 |
| Azure SQL | Database, Managed Instance, SQL Database in Microsoft Fabric |
| Database driver | pyodbc (default), mssql-python |
| Native connectivity | Microsoft ODBC Driver 17/18 with pyodbc; Microsoft ODBC Driver 18 supplied by mssql-python-odbc with mssql-python |
mssql-django 2.0 requires mssql-python and therefore supports only platforms with a compatible mssql-python distribution. SUSE Linux ARM64 is not supported. Users on other platforms must remain on mssql-django 1.8.0.
Quick Start
-
Install mssql-django (pulls in Django, mssql-python, pyodbc, and tzdata automatically):
pip install mssql-django -
Configure your
settings.py:
DATABASES = {
'default': {
'ENGINE': 'mssql',
'NAME': 'mydb',
'USER': 'user@myserver',
'PASSWORD': 'password',
'HOST': 'myserver.database.windows.net',
'PORT': '',
},
}
# Set this to False to turn off connection pooling for both database drivers.
DATABASE_CONNECTION_POOLING = False
Configuration Reference
Standard Django Settings
| Setting | Type | Description |
|---|