mssql-python-rs
Native runtime for the
mssql-python SQL Server and
Azure SQL driver. Install and use mssql-python for the Python database API;
this package supplies its native components:
mssql_py_core— a PyO3 extension that implements the SQL Server TDS protocol in Rust. It backs high-throughput paths (such as bulk copy) for themssql-pythondriver.mssqlodbc(alpha) — an ODBC driver for SQL Server, implemented in Rust. It exposes the native ODBC C API. It is under active development and validation for use as an opt-in backend for themssql-pythondriver. It is not yet a complete general-purpose replacement for Microsoft ODBC Driver 18 for SQL Server.
Platforms
Prebuilt wheels for CPython 3.10+:
- Windows — x64, and ARM64 (CPython 3.11+)
- macOS 15+ — universal2 (x86_64 + arm64)
- Linux — glibc (
manylinux_2_28,manylinux_2_34) and musl (musllinux_1_2), on x86_64 and aarch64
The Linux wheels require system OpenSSL: 1.1 for manylinux_2_28, or 3 for
manylinux_2_34 and musllinux_1_2 (libssl3 on Alpine). Windows and macOS
do not require OpenSSL.
Documentation
For SDK authors integrating the native runtime:
- Connection settings for native connection options and defaults.
- Bulk-copy behavior for datetime string precision, offsets, and validation.
Native async authentication preview (AQE)
Async Query Execution (AQE) authentication is a native mssql_py_core preview,
subject to breaking changes without notice and not intended for production use.
The example below calls PyAsyncConnection directly; it does not imply that the
downstream mssql-python public async wrapper exposes these authentication options.
Use a build containing this preview, not an older published package.
Built-in credentials require the azure-async extra, which installs
azure-identity>=1.25.3 and aiohttp>=3.12. For a local preview wheel, replace the
placeholder filename with the wheel for your platform:
python -m pip install "/path/to/mssql_python_rs-<version>-<python>-<abi>-<platform>.whl[azure-async]"
Built-in credentials
Built-in acquisition uses azure.identity.aio on the caller's asyncio loop.
It supports Azure Public Cloud only, including the SQL scope
https://database.windows.net/.default and validated public FedAuth authorities.
Sovereign-cloud built-in acquisition is not supported.
authentication |
Async Azure Identity credential | Native context options |
|---|---|---|
ActiveDirectoryDefault |
DefaultAzureCredential |
Configure the Azure Identity credential chain; the driver requests the server's validated FedAuth tenant. |
ActiveDirectoryMSI |
ManagedIdentityCredential |
Omit user_name for system-assigned identity; set it to the client ID for user-assigned identity. |
ActiveDirectoryServicePrincipal |
ClientSecretCredential |
Set user_name to the client ID and password to the client secret; the tenant comes from FedAuth. |
Interactive, Device Code, Entra Integrated, and Entra Username/Password
(deprecated) are not supported as built-in async modes in this preview.
Synchronous mssql-python supports additional modes through synchronous Azure
Identity and/or native ODBC authentication; AQE does not yet provide full
authentication-mode parity.
The Azure Identity async API
does not expose counterparts to InteractiveBrowserCredential,
DeviceCodeCredential, or UsernamePasswordCredential, nor an equivalent
integrated-auth credential. The synchronous
username/password credential is deprecated
because it does not support MFA. These are limitations of the available SDK
surface and this preview, not a claim that the flows are inherently impossible
asynchronously. The driver does not wrap synchronous credentials in worker
threads as a fallback. Default can use an existing Azure CLI login, but that
does not constitute built-in Interactive or Device Code support.
These exclusions apply to built-in modes. Caller-owned custom providers may implement other flows if they satisfy the async contract below.
Configure an Azure identity with access to the database, and set SQL_SERVER and
SQL_DATABASE before running this native-only example:
import asyncio
import os
from mssql_py_core import PyAsyncConnection
async def main():
context = {
"server": os.environ["SQL_SERVER"],
"database": os.environ["SQL_DATABASE"],
"authentication": "ActiveDirectoryDefault",
"encryption": "Mandatory",
"trust_server_certificate": False,
"connect_timeout": 30,
"connect_retry_count": 0,
}
connection = await PyAsyncConnection.connect(context, autocommit=True)
try:
cursor = connection.cursor()
try:
await cursor.execute("SELECT 1", use_prepare=False)
print(await cursor.fetchone())
finally:
await cursor.close()
finally:
await connection.close()
asyncio.run(main())
Connect errors
Native async TDS connect failures use the same mssql_py_core DB-API exception
mapping for every authentication mode. Transport, TLS, and login-timeout failures
raise OperationalError; server login errors raise DatabaseError with
sql_errors and info_messages diagnostics. This replaces the previous
RuntimeError mapping for SqlPassword and raw access-token connect failures.
Async Entra cancellation during initial login still raises
asyncio.CancelledError. Connection lifecycle and ownership rejections retain
their existing behavior.
Custom providers and cleanup
Pass a caller-owned credential using the keyword-only token_provider argument
to PyAsyncConnection.connect(context, token_provider=credential). Remove
authentication from the example context, and do not supply non-empty
user_name or password, an access token, another token factory, or
trusted_connection="Yes".
The provider must have a callable get_token(scope) returning an awaitable.
Its result must expose a non-empty string token, such as Azure Identity's
AccessToken. The driver passes one scope argument and no tenant keyword;
custom providers retain their own tenant policy. Custom providers do not require
the extra unless their implementation uses its dependencies.
- Caller-owned: The driver never closes a custom credential. Keep it usable while the connection may acquire tokens, and close it yourself after use.
- Driver-owned: A built-in credential is created for each acquisition attempt and closed before its token is delivered to TDS. There is no global async credential cache.
- Cleanup: Acquisition runs on the originating asyncio loop and shares the native login deadline. Driver-owned cleanup has a separate five-second limit; cleanup failure after successful acquisition fails login. Keep the loop running until credential tasks settle. Cancellation is cooperative; a credential that suppresses it may continue running after the caller stops waiting.
Provider cancellation during session recovery remains a known limitation: it may
be retried or surface as OperationalError. The example disables recovery with
connect_retry_count=0; preserving recovery-time cancellation requires a separate
TDS and py-core change.
For contributors, the async pool context guide maps internal types and ownership; it does not describe an enabled pooling API.
License
Licensed under the MIT License.
Metadata
Release files for mssql-python-rs 0.5.0
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Built distributions (wheels)
Total release size: 114.0 MB
Release files / mssql_python_rs-0.5.0-cp310-abi3-win_arm64.whl
| Download URL | mssql_python_rs-0.5.0-cp310-abi3-win_arm64.whl |
|---|---|
| Size | 10.5 MB |
| Tags | CPython 3.10 Windows ARM64 abi3 |
|
SHA-256 checksum How to use checksums |
52c9398398408740dc72eab631a92d2f09223bb004b22866bba8773d852ea44c
|
|
BLAKE2b-256 checksum How to use checksums |
f6f0ebb9cd6a677b0a536508c7cb49d3cd700ccd69ef88fdd875b854f55c4e9c
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
RestSharp/106.13.0.0
|
Release files / mssql_python_rs-0.5.0-cp310-abi3-win_amd64.whl
| Download URL | mssql_python_rs-0.5.0-cp310-abi3-win_amd64.whl |
|---|---|
| Size | 11.3 MB |
| Tags | CPython 3.10 Windows x86-64 abi3 |
|
SHA-256 checksum How to use checksums |
d9d1a7b1e3496edce97275cf5a6b821ef107c1fa65c746889ff15487b9c91727
|
|
BLAKE2b-256 checksum How to use checksums |
54fbcff60f6d816d754c8ea3f9acac95e053697c12c93a37b5434f9160da1ee7
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
RestSharp/106.13.0.0
|
Release files / mssql_python_rs-0.5.0-cp310-abi3-musllinux_1_2_x86_64.whl
| Download URL | mssql_python_rs-0.5.0-cp310-abi3-musllinux_1_2_x86_64.whl |
|---|---|
| Size | 11.9 MB |
| Tags | CPython 3.10 Linux musl 1.2+ x86-64 abi3 |
|
SHA-256 checksum How to use checksums |
ca5d60e2f2fcbed11eb22bb560667ef6566ec5a78b1df14053588ca2bb73a39c
|
|
BLAKE2b-256 checksum How to use checksums |
b22a7f2b766d0e54dc4c909ab67aa8cd28af2a8d6567141a82a4de93797c2e6b
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
RestSharp/106.13.0.0
|
Release files / mssql_python_rs-0.5.0-cp310-abi3-musllinux_1_2_aarch64.whl
| Download URL | mssql_python_rs-0.5.0-cp310-abi3-musllinux_1_2_aarch64.whl |
|---|---|
| Size | 11.3 MB |
| Tags | CPython 3.10 Linux musl 1.2+ ARM64 abi3 |
|
SHA-256 checksum How to use checksums |
2c3011657df08b50f7a10f1cd892c32a6afb7009b73bf920da2abfffeb4495fa
|
|
BLAKE2b-256 checksum How to use checksums |
42d495e3f2717add0cb98ad076da5adaa5d54d0e0285c935e2dafe788d3c31fd
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
RestSharp/106.13.0.0
|
Release files / mssql_python_rs-0.5.0-cp310-abi3-manylinux_2_34_x86_64.whl
| Download URL | mssql_python_rs-0.5.0-cp310-abi3-manylinux_2_34_x86_64.whl |
|---|---|
| Size | 11.9 MB |
| Tags | CPython 3.10 Linux glibc 2.34+ x86-64 abi3 |
|
SHA-256 checksum How to use checksums |
8fa92e1dcaeb5eb32b645aea4b6c33db39b0650df9c890c14aaa2126dde29f32
|
|
BLAKE2b-256 checksum How to use checksums |
9cfa278cafac6467a58b5216e1654dd91b2a07bad0a011ad61eb5ca67cde42d5
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
RestSharp/106.13.0.0
|
Release files / mssql_python_rs-0.5.0-cp310-abi3-manylinux_2_34_aarch64.whl
| Download URL | mssql_python_rs-0.5.0-cp310-abi3-manylinux_2_34_aarch64.whl |
|---|---|
| Size | 11.4 MB |
| Tags | CPython 3.10 Linux glibc 2.34+ ARM64 abi3 |
|
SHA-256 checksum How to use checksums |
68bd5099ae964e73d5b55af598c346f12e4b587a8e6a5a0e50c97366d57741ea
|
|
BLAKE2b-256 checksum How to use checksums |
dcd5e7a7a6d76e19b3e42e95aa9115df9e3a51e3ef3239cc27b09f06583d0f91
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
RestSharp/106.13.0.0
|
Release files / mssql_python_rs-0.5.0-cp310-abi3-manylinux_2_28_x86_64.whl
| Download URL | mssql_python_rs-0.5.0-cp310-abi3-manylinux_2_28_x86_64.whl |
|---|---|
| Size | 11.9 MB |
| Tags | CPython 3.10 Linux glibc 2.28+ x86-64 abi3 |
|
SHA-256 checksum How to use checksums |
fe63801d3b05c4c4b52ae890dcab96dc9c3fa826c148fd4adf40d853a53b4354
|
|
BLAKE2b-256 checksum How to use checksums |
8fc63ea3570599e22b84df5415999cb0fb2ce4100fcdc342f2062fc60f43930a
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
RestSharp/106.13.0.0
|
Release files / mssql_python_rs-0.5.0-cp310-abi3-manylinux_2_28_aarch64.whl
| Download URL | mssql_python_rs-0.5.0-cp310-abi3-manylinux_2_28_aarch64.whl |
|---|---|
| Size | 11.4 MB |
| Tags | CPython 3.10 Linux glibc 2.28+ ARM64 abi3 |
|
SHA-256 checksum How to use checksums |
04b344dfca8fe27034541bbba1fb783f0a0f5e031d36dd142f17eb4a49e1bc49
|
|
BLAKE2b-256 checksum How to use checksums |
e557d14baff0651015162a63873d28f7632925396be8f8892edfc15d94720774
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
RestSharp/106.13.0.0
|
Release files / mssql_python_rs-0.5.0-cp310-abi3-macosx_15_0_universal2.whl
| Download URL | mssql_python_rs-0.5.0-cp310-abi3-macosx_15_0_universal2.whl |
|---|---|
| Size | 22.3 MB |
| Tags | CPython 3.10 abi3 macOS 15.0+ universal2 (ARM64, x86-64) |
|
SHA-256 checksum How to use checksums |
f1d2bcf8cae7031257819ea2249aa4703522ff7d4d8aacac5db6e53e845c5cc5
|
|
BLAKE2b-256 checksum How to use checksums |
088c55f75cf5ad3b8de18137ef4372bdbe8ef72dad00264248f15608ddbd08ca
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
RestSharp/106.13.0.0
|
Security for mssql-python-rs 0.5.0
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.