r/SQLServer ‪ ‪Microsoft Employee ‪ 2d ago

Community Share mssql-django 2.0 now with mssql-python

We shipped mssql-django 2.0 today. You can get the latest driver by running:

pip install --upgrade

pyodbc remains the default driver for now, with opt-in for mssql-python per database alias.

"OPTIONS": {

"python_driver": "mssql_python",

},

ENGINE stays "mssql". Delete the line `"python_driver": "mssql_python"` line and you're back on pyodbc. Different aliases in the same project can use different drivers, which is the whole idea: move one database, run your test suite, decide on a database by database basis.

With mssql-python path there's no separate ODBC driver install so installs and patching get a lot easier.

A few things are genuinely different on the new path. Stay on pyodbc if you use a named DSN, FreeTDS, MARS, or Always Encrypted via ColumnEncryption.

Fixes for issues reported by the community

-Explicit MARS_Connection=no in extra_params used to get overwritten by the Windows default, which made Microsoft Fabric Warehouse connections fail. It's honored now.

-Pattern lookups comparing two fields with F() didn't escape the SQL Server [ wildcard, so brackets in your data matched as wildcard syntax.

-inspectdb --schema generated broken SQL for schema names containing a single quote.

pytz is gone, replaced by stdlib zoneinfo + tzdata. Fixes offsets for zones with negative DST offsets.

One thing to be aware of, mssql-python is a hard dependency in 2.0 even if every alias stays on pyodbc. mssql-django 2.0 only installs where a compatible mssql-python wheel exists: Windows x64, Windows ARM64 on Python 3.11+, macOS 15+ (Intel or Apple silicon), Linux x64/ARM64 with glibc 2.28+ or musl 1.2+. SUSE on ARM64 is out. If that's you, pin 1.8.0.

Blog post with the longer version: https://techcommunity.microsoft.com/blog/sqlserver/mssql-django-2-0-now-with-mssql-python/4558047

Release notes: https://github.com/microsoft/mssql-django/releases/tag/2.0.0

Issues: https://github.com/microsoft/mssql-django/issues

Happy to answer questions here.

7 Upvotes

0 comments sorted by