Skip to main content

A Python library for interacting with Microsoft SQL Server

Project description

General Availability Release

mssql‑python is now Generally Available (GA) as Microsoft’s official Python driver for SQL Server, Azure SQL, and SQL databases in Fabric. This release delivers a production‑ready, high‑performance, and developer‑friendly experience.

What makes mssql-python different?

Powered by DDBC – Direct Database Connectivity

Most Python SQL Server drivers, including pyodbc, route calls through the Driver Manager, which has slightly different implementations across Windows, macOS, and Linux. This results in inconsistent behavior and capabilities across platforms. Additionally, the Driver Manager must be installed separately, creating friction for both new developers and when deploying applications to servers.

At the heart of the mssql-python driver is DDBC (Direct Database Connectivity) — a lightweight, high-performance C++ layer that replaces the platform’s Driver Manager.

Key Advantages:

  • Provides a consistent, cross-platform backend that handles connections, statements, and memory directly.
  • Interfaces directly with the native SQL Server drivers.
  • Integrates with the same TDS core library that powers the ODBC driver.

Why is this architecture important?

By simplifying the architecture, DDBC delivers:

  • Consistency across platforms
  • Lower function call overhead
  • Zero external dependencies on Windows (pip install mssql-python is all you need)
  • Full control over connections, memory, and statement handling

Built with PyBind11 + Modern C++ for Performance and Safety

To expose the DDBC engine to Python, mssql-python uses PyBind11 – a modern C++ binding library.

PyBind11 provides:

  • Native-speed execution with automatic type conversions
  • Memory-safe bindings
  • Clean and Pythonic API, while performance-critical logic remains in robust, maintainable C++.

What's new in v1.7.0

Enhancements

  • UTF-16 String Performance - UTF-16 strings are now handled using simdutf and std::u16string, significantly reducing encoding/decoding overhead for Unicode-heavy workloads.
  • execute() Hot Path Optimization - Optimized the execute() hot path with soft cursor reset, prepared statement caching, and guarded diagnostics, reducing per-call overhead for high-frequency queries.

Bug Fixes

  • Login Failure Exception Type - Login failures are now correctly raised as mssql_python exceptions (e.g. OperationalError) instead of a generic RuntimeError.
  • GIL Release During ODBC Calls - The driver now releases the GIL during all blocking ODBC statement, fetch, transaction, and connection attribute calls, improving concurrency for multi-threaded applications.
  • executemany Decimal Sign Change - Fixed a RuntimeError in executemany when decimal values changed signs across rows.
  • CP1252 VARCHAR Inconsistency - Fixed inconsistent retrieval of CP1252-encoded data in VARCHAR columns between Windows and Linux.
  • RHEL 8 / glibc 2.28 Wheel Support - Added manylinux_2_28 build targets, enabling installation on Red Hat Enterprise Linux 8 and other glibc 2.28 compatible distributions.
  • macOS Python 3.10 Universal2 Wheel - Fixed missing universal2 wheel for Python 3.10 on macOS, restoring native Apple Silicon support for that version.
  • BulkCopy Empty String in NVARCHAR(MAX) - Fixed cursor.bulkcopy() failing with SQL error 40197/4804 when any row contained an empty string "" in an NVARCHAR(MAX) or VARCHAR(MAX) column. (via mssql_py_core)

What's new in v1.6.0

Enhancements

  • Connection String Sanitization - Connection string sanitization has been migrated from regex-based to parser-based logic, making it more robust and consistent with connection string parsing rules.

Bug Fixes

  • GIL Release During ODBC Connect/Disconnect - The driver now releases the GIL during blocking ODBC connect and disconnect calls, improving concurrency for multi-threaded applications.
  • setinputsizes() SQL_DECIMAL Crash Fix - Fixed a crash in cursor.setinputsizes() when specifying SQL_DECIMAL type hints.
  • ODBC Catalog fetchone() Fix - Fixed an issue where fetchone() on ODBC catalog method results returned incorrect data.
  • cursor.execute() Invalid Cursor State Fix - Fixed cursor.execute() raising an Invalid cursor state error when called with reset_cursor=False.
  • executemany Type Annotation Fix - Corrected the type annotation for executemany seq_of_parameters parameter to accept Mapping types.
  • setup_logging Path Traversal Guard - Added path canonicalization and traversal guard to setup_logging's log_file_path parameter to prevent path traversal issues.

For more information, please visit the project link on Github: https://github.com/microsoft/mssql-python

If you have any feedback, questions or need support please mail us at mssql-python@microsoft.com.

What's Next

As we continue to refine the driver and add new features, you can expect regular updates, optimizations, and bug fixes. We encourage you to contribute, provide feedback and report any issues you encounter, as this will help us improve the driver.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distributions

No source distribution files available for this release.See tutorial on generating distribution archives.

Built Distributions

If you're not sure about the file name format, learn more about wheel file names.

mssql_python-1.7.0-cp312-cp312-macosx_15_0_universal2.whl (28.1 MB view details)

Uploaded CPython 3.12macOS 15.0+ universal2 (ARM64, x86-64)

mssql_python-1.7.0-cp311-cp311-win_arm64.whl (18.5 MB view details)

Uploaded CPython 3.11Windows ARM64

mssql_python-1.7.0-cp311-cp311-win_amd64.whl (15.5 MB view details)

Uploaded CPython 3.11Windows x86-64

mssql_python-1.7.0-cp311-cp311-musllinux_1_2_x86_64.whl (25.8 MB view details)

Uploaded CPython 3.11musllinux: musl 1.2+ x86-64

mssql_python-1.7.0-cp311-cp311-musllinux_1_2_aarch64.whl (25.4 MB view details)

Uploaded CPython 3.11musllinux: musl 1.2+ ARM64

mssql_python-1.7.0-cp311-cp311-manylinux_2_28_x86_64.whl (26.0 MB view details)

Uploaded CPython 3.11manylinux: glibc 2.28+ x86-64

mssql_python-1.7.0-cp311-cp311-manylinux_2_28_aarch64.whl (25.5 MB view details)

Uploaded CPython 3.11manylinux: glibc 2.28+ ARM64

mssql_python-1.7.0-cp311-cp311-macosx_15_0_universal2.whl (28.1 MB view details)

Uploaded CPython 3.11macOS 15.0+ universal2 (ARM64, x86-64)

mssql_python-1.7.0-cp310-cp310-win_amd64.whl (15.5 MB view details)

Uploaded CPython 3.10Windows x86-64

mssql_python-1.7.0-cp310-cp310-musllinux_1_2_x86_64.whl (25.2 MB view details)

Uploaded CPython 3.10musllinux: musl 1.2+ x86-64

mssql_python-1.7.0-cp310-cp310-musllinux_1_2_aarch64.whl (25.0 MB view details)

Uploaded CPython 3.10musllinux: musl 1.2+ ARM64

mssql_python-1.7.0-cp310-cp310-manylinux_2_28_x86_64.whl (25.3 MB view details)

Uploaded CPython 3.10manylinux: glibc 2.28+ x86-64

mssql_python-1.7.0-cp310-cp310-manylinux_2_28_aarch64.whl (25.0 MB view details)

Uploaded CPython 3.10manylinux: glibc 2.28+ ARM64

mssql_python-1.7.0-cp310-cp310-macosx_15_0_universal2.whl (28.1 MB view details)

Uploaded CPython 3.10macOS 15.0+ universal2 (ARM64, x86-64)

File details

Details for the file mssql_python-1.7.0-cp312-cp312-macosx_15_0_universal2.whl.

File metadata

File hashes

Hashes for mssql_python-1.7.0-cp312-cp312-macosx_15_0_universal2.whl
Algorithm Hash digest
SHA256 f579bdc9b160e116d582e572cc0a77f55486a9e0903935d3e3f21442ba7eebd9
MD5 1fb13371210fe1455a8234ac4eaaa07f
BLAKE2b-256 23c1f862976278a52b5c8ae4347ce862c49d13c2d82881272b36b41157419b09

See more details on using hashes here.

File details

Details for the file mssql_python-1.7.0-cp311-cp311-win_arm64.whl.

File metadata

File hashes

Hashes for mssql_python-1.7.0-cp311-cp311-win_arm64.whl
Algorithm Hash digest
SHA256 35160ce35a620acf6e915b76c34cf60e24cbe210bb6424a86830086789088907
MD5 a402961146b3f7f1ce7c55f305d3d39d
BLAKE2b-256 98ab4f548bd411d82c5c6ac4cd80c14316e90b4236bb7ad644919b65e6b8fc9f

See more details on using hashes here.

File details

Details for the file mssql_python-1.7.0-cp311-cp311-win_amd64.whl.

File metadata

File hashes

Hashes for mssql_python-1.7.0-cp311-cp311-win_amd64.whl
Algorithm Hash digest
SHA256 2cf2ab96cd3d08286eabc4640a95704c894d4fc01d3c1b4a616dca288a297470
MD5 08afedf4aec4182a01dbdc6c3cbb536b
BLAKE2b-256 c655783f6524d69d2de21730271d33aa301aef441355fa45b71070c7d1832e30

See more details on using hashes here.

File details

Details for the file mssql_python-1.7.0-cp311-cp311-musllinux_1_2_x86_64.whl.

File metadata

File hashes

Hashes for mssql_python-1.7.0-cp311-cp311-musllinux_1_2_x86_64.whl
Algorithm Hash digest
SHA256 332a699f5f3c4d71c0216a31b6d6a695f8479ac53cee3492482c0c27b2be45dc
MD5 abe78a3497c2b9d97eae3bfdd48b8c77
BLAKE2b-256 97de0a3d201c365a86f912ceaebd644615e5de24e88fb9dd6a402855a687a410

See more details on using hashes here.

File details

Details for the file mssql_python-1.7.0-cp311-cp311-musllinux_1_2_aarch64.whl.

File metadata

File hashes

Hashes for mssql_python-1.7.0-cp311-cp311-musllinux_1_2_aarch64.whl
Algorithm Hash digest
SHA256 e0db9a46b5b57a42474df16c4f3b4a49610dffa1183557a86b91a5c44b932ec0
MD5 fdf849bc7c874783e087cd05ecc35fc1
BLAKE2b-256 dad6b8ab098648ec4098c4e0ad73c5d255f961d14e71cd53f3b94d09aab3778b

See more details on using hashes here.

File details

Details for the file mssql_python-1.7.0-cp311-cp311-manylinux_2_28_x86_64.whl.

File metadata

File hashes

Hashes for mssql_python-1.7.0-cp311-cp311-manylinux_2_28_x86_64.whl
Algorithm Hash digest
SHA256 c20ebd654fc564a71760f2f065eaf3912cdef1e0a5ac8452fb0e5581c4102a17
MD5 bdc784a7b15056596fc2c450064fafb2
BLAKE2b-256 c136eed9618141f92719ad5068ef8f745a6ca69c0c8b424390e8eb1e4fa90acf

See more details on using hashes here.

File details

Details for the file mssql_python-1.7.0-cp311-cp311-manylinux_2_28_aarch64.whl.

File metadata

File hashes

Hashes for mssql_python-1.7.0-cp311-cp311-manylinux_2_28_aarch64.whl
Algorithm Hash digest
SHA256 01000fb670858e3edbbe36c779cb968f0ee233caab6f9256661952fb1bd777ae
MD5 79f223b25f597b77918b2df022fc32dc
BLAKE2b-256 50d0252e7d8724a8902745477cb475f2dc895a8a4db96da6e36ab2a04084030d

See more details on using hashes here.

File details

Details for the file mssql_python-1.7.0-cp311-cp311-macosx_15_0_universal2.whl.

File metadata

File hashes

Hashes for mssql_python-1.7.0-cp311-cp311-macosx_15_0_universal2.whl
Algorithm Hash digest
SHA256 66ba54da00dce89c1f4fdec426220c6df9b35405da9d1e786077caf5327c8a3f
MD5 2552501467b142a4f812bfa40fc0c88e
BLAKE2b-256 8b03f868dffc3e4174c7a7d9485c194f945ce9458182ced8b81bdcf5c8ce8ba4

See more details on using hashes here.

File details

Details for the file mssql_python-1.7.0-cp310-cp310-win_amd64.whl.

File metadata

File hashes

Hashes for mssql_python-1.7.0-cp310-cp310-win_amd64.whl
Algorithm Hash digest
SHA256 77425b03cbc6950ef636d0abb4245db86193e44ea9966eb86e4f6417158ee89b
MD5 6f9b535051f9cdba0e9fbdbfbe090e9f
BLAKE2b-256 41c243a783d378e178dad2ff7c9fcd75779ea31c06c9d50a1974ee7af2fd3226

See more details on using hashes here.

File details

Details for the file mssql_python-1.7.0-cp310-cp310-musllinux_1_2_x86_64.whl.

File metadata

File hashes

Hashes for mssql_python-1.7.0-cp310-cp310-musllinux_1_2_x86_64.whl
Algorithm Hash digest
SHA256 50c6fee5e2ec0fa511a191928f951c304012dbadbe4e7ba4d20c2c9d61608b93
MD5 7f85afdeabb4c2c1da362a7fe29775e4
BLAKE2b-256 42b9ef2cd0027f1bfb0a9188ff7bb54f5f2902704face0b2cde06b4a85d5aa66

See more details on using hashes here.

File details

Details for the file mssql_python-1.7.0-cp310-cp310-musllinux_1_2_aarch64.whl.

File metadata

File hashes

Hashes for mssql_python-1.7.0-cp310-cp310-musllinux_1_2_aarch64.whl
Algorithm Hash digest
SHA256 525239ac6c842b58292f544b5bc0983d977c5a8542f4f08d11b7a5aaa0c2f9e4
MD5 c7b6287acfad93a5d846554dfecb98b0
BLAKE2b-256 d5493849448e1ab0d456a4739171f0aedf8e4522e122ddc0c28635a9be73fdb5

See more details on using hashes here.

File details

Details for the file mssql_python-1.7.0-cp310-cp310-manylinux_2_28_x86_64.whl.

File metadata

File hashes

Hashes for mssql_python-1.7.0-cp310-cp310-manylinux_2_28_x86_64.whl
Algorithm Hash digest
SHA256 adc21563d2442c9f52aae7acc31861369d03a3f1f5dfb720d634a2906721c255
MD5 e33944e5a203edb5941754d04a9be7d2
BLAKE2b-256 0c410a5d20095798f6fdbf89e2b9e3628fd43cb8a69cc06718deb6323ea0a4d1

See more details on using hashes here.

File details

Details for the file mssql_python-1.7.0-cp310-cp310-manylinux_2_28_aarch64.whl.

File metadata

File hashes

Hashes for mssql_python-1.7.0-cp310-cp310-manylinux_2_28_aarch64.whl
Algorithm Hash digest
SHA256 ade5ca3b555771c17fdc87933cc6fcd495fc1fa8fa097cbd85dcfbec44d68e51
MD5 f30ade9a424b1a65f20a3be65243ed31
BLAKE2b-256 e3595c9ba29a63c2d259db7f3d45283c9b5aba111717544890b4031dbbbced39

See more details on using hashes here.

File details

Details for the file mssql_python-1.7.0-cp310-cp310-macosx_15_0_universal2.whl.

File metadata

File hashes

Hashes for mssql_python-1.7.0-cp310-cp310-macosx_15_0_universal2.whl
Algorithm Hash digest
SHA256 bb5d6667df7de57c899f4ba1a81f88de3221a0f4ebf34a6019753b1e59f6d091
MD5 bdb90885697f074761345dfaca6983d5
BLAKE2b-256 8ee08ae632671b5b595574c06545df1b406a809f88a77877ab74be24e4ebd56a

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page