skillfed

mssql-django

Django backend for Microsoft SQL Server

mssql-django v1.8.0 463.8K downloads/30d#6,519 on PyPI399
Permissive license BSD Active released

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

uv

uv add mssql-django

poetry

poetry add mssql-django

Installing 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

Framework :: DjangoFramework :: Django :: 3.2Framework :: Django :: 4.0Framework :: Django :: 4.1Framework :: Django :: 4.2Framework :: Django :: 5.0Framework :: Django :: 5.1Framework :: Django :: 5.2Framework :: Django :: 6.0Framework :: Django :: 6.1License :: OSI Approved :: BSD LicenseOperating System :: Microsoft :: WindowsOperating System :: POSIX :: LinuxProgramming Language :: PythonProgramming Language :: Python :: 3Programming Language :: Python :: 3.10Programming Language :: Python :: 3.11Programming Language :: Python :: 3.12Programming Language :: Python :: 3.13Programming Language :: Python :: 3.14Programming Language :: Python :: 3.8Programming Language :: Python :: 3.9

Tags

django sql server backenddjango mssql databaseazure sql djangosql server orm djangodjango odbc connectormicrosoft sql djangodjango database backend mssql
django-backendsql-serverazure-sql

More Front-Ends packages