Repository navigation
Releases
v1.9.0
mssql-python - v1.19.0
View mssql-python 1.19.0 on PyPI
View mssql-python on Conda (Microsoft channel)
Enhancements
- Connection Retry Policy (#751)
What changed: Add optional RetryPolicy and retry_policy= configuration for connect() and Connection() initialization, with configurable transient SQLSTATEs, attempt limits, and backoff.
Who benefits: Applications that need bounded retries for transient connection failures.
Impact: Connection establishment can retry automatically when explicitly configured. Existing behavior is unchanged without a policy; statement retries are not included.
PR #751 | GitHub Issue #682 - Thanks @Om-singhaI for the contribution!
- Table-Valued Parameters (#789)
What changed: Add TableValuedParameter(type_name, columns, rows, *, schema=None) and synchronous execution through the default ODBC provider, streaming rows within one SQL execution.
Who benefits: Applications passing structured rows to SQL Server table-valued parameters.
Impact: Explicit table definitions support synchronous iterators, empty inputs, and nullable cells. Async integration, TVP executemany(), TVP setinputsizes() overrides, and the alternate mssql-odbc provider are not supported by this change.
PR #789
What changed: Add optional sqlstate and native_error attributes to DB-API exceptions, retaining paired diagnostics from synchronous ODBC errors.
Who benefits: Applications classifying database failures without parsing English error messages.
Impact: Callers can inspect structured diagnostics while retaining existing exception classes, messages, arguments, and serialization compatibility. Unavailable diagnostics, including async Rust/TDS metadata, remain None; retry rules are unchanged.
What changed: Add operation-scoped native cancellation foundations and public synchronous Cursor.cancel() with completion fences and checked recovery.
Who benefits: Applications requesting cancellation of supported synchronous execute, fetch, iteration, and next-result operations.
Impact: Cancellation requests target the captured active operation rather than a replacement operation. Cancellation is best effort, has no response deadline, and does not implicitly roll back transactions; wait for operation completion before reuse. Arrow, bulk-copy, and async cancellation are outside this public API's supported scope.
- POSIX Native Binary Hardening (#810)
What changed: Enable native-extension stack protection and supported fortification on POSIX, plus full RELRO, immediate binding, and non-executable stack declarations on Linux.
Who benefits: Users deploying the native extension on Linux and macOS.
Impact: Shipped native builds gain additional compiler and linker defenses. Windows behavior is unchanged.
PR #810
Bug Fixes
- Lossless Batch Parameter Inference (#907)
What changed: Correct executemany inference across Unicode, Decimal, and mixed-type batches, preserving embedded and trailing NULs during binding and retrieval.
Who benefits: Applications inserting or updating batches whose values differ in text encoding, precision, scale, or compatible type.
Impact: Batch inference preserves values and explicit input-size overrides instead of losing non-ASCII text or truncating data. Incompatible mixed types use individual execution to preserve values.
- Numeric Binding for Money-Range Decimals (#752)
What changed: Bind auto-detected executemany Decimal columns as SQL_NUMERIC with batch-wide precision and scale, replacing the money-range VARCHAR shortcut.
Who benefits: Applications comparing or binding money-range Decimal values against numeric columns through executemany.
Impact: Avoid numeric overflows caused by the shortcut while retaining the existing explicit DECIMAL/NUMERIC input-size string path.
PR #752 | GitHub Issue #745 - Thanks @vyrnsynx for the contribution!
- Korean VARCHAR Encoding (#910)
What changed: Require CP949 conversion modules in manylinux package builds and verify conversion fidelity.
Who benefits: Applications using Korean VARCHAR data with the manylinux wheels.
Impact: Restore conversion support that was missing when the wheel environment lacked the required glibc conversion modules.
PR #910
Contributors
mssql-python 1.18.0
mssql-python 1.18.0
This release improves fetching and repeated-query performance, adds custom application names, and strengthens pooled connection and Arrow reader reliability.
Release Highlights
Faster Fetching and Repeated Queries (#847, #858, #852, #891, #888, #886)
- What changed: Reuse row-mapping metadata and cursor-scoped fetch state, reduce output-converter overhead, cache pyformat conversion, and retain compatible prepared-statement bindings.
- Who benefits: Applications converting rows to dictionaries, fetching results one row at a time, using output converters, or repeatedly executing parameterized SQL.
- Impact: Less repeated preparation, conversion, and allocation work while retaining compatibility fallbacks and existing result semantics.
PR #847 | PR #858 | PR #852 | PR #891 | PR #888 | PR #886 | Thanks Daniel Caspi (@dxdc) for the pyformat contribution.
pip install --upgrade mssql-pythonView mssql-python 1.18.0 on PyPI
View mssql-python on Conda (Microsoft channel)
Enhancements
- Custom Application Names (#884)
What changed: Connection strings now accept APP and Application Name, sharing the effective application name across synchronous, async, and bulk-copy paths.
Who benefits: Applications using server-side monitoring or telemetry to distinguish workloads.
Impact: Custom names appear as MSSQL-Python|<user name>. The async and bulk-copy default changes from mssql-python to MSSQL-Python; exact-name telemetry filters may need updating.
- Faster Row-to-Dictionary Conversion (#847)
What changed: Reuse row-mapping metadata and native mapping infrastructure when converting fetched rows to dictionaries.
Who benefits: Applications that frequently call dict(row._mapping), particularly on wide results.
Impact: Row-to-dictionary conversion spends less work rebuilding mapping information.
PR #847
- Faster Single-Row Fetching (#858)
What changed: Reuse cursor-scoped native state for eligible fetchone(), fetchmany(1), fetchval(), and iteration paths, retaining Python fallbacks.
Who benefits: Applications that consume results one row at a time.
Impact: Eligible fetches avoid repeated Python-side dispatch and preparation while preserving custom behavior.
PR #858
- Faster Output-Converter Batching (#852)
What changed: Reduce conversion and row-construction overhead when fetching batches with output converters.
Who benefits: Applications using output converters with fetchall() or batch-oriented fetchmany().
Impact: Eligible callbacks receive their bytes without unnecessary intermediate string conversion, preserving callback order and NULL handling.
PR #852
- Faster Size-One Text Fetches (#891)
What changed: Avoid rebuilding text-fetch preparation after ordinary row-count updates during fetchmany(1).
Who benefits: Applications fetching text results one row at a time.
Impact: Repeated size-one fetches reuse the established native path without prefetching rows.
PR #891
- Faster Pyformat Conversion (#888)
What changed: Convert pyformat placeholders in a single pass and cache converted statements.
Who benefits: Applications repeatedly executing pyformat SQL, including wide SQLAlchemy insert batches.
Impact: Repeated statements avoid rescanning and replacing the SQL once for each parameter.
- Prepared Statement Reuse (#886)
What changed: Retain parameter bindings when re-executing the same prepared SQL with compatible parameter definitions.
Who benefits: Applications repeatedly executing parameterized statements on the same cursor.
Impact: Drivers can reuse the prepared statement with sp_execute instead of preparing it again on every call.
- Faster Rust-Backed Execution (#896)
What changed: Reduce SQL-text scanning, transcoding, and RPC parameter-serialization overhead in Rust-backed execution paths.
Who benefits: Applications using the opt-in Rust ODBC provider or the native async core, especially with parameter-heavy statements.
Impact: Eligible workloads avoid repeated text passes, per-parameter allocations, and unnecessary async serialization work. (via mssql-python-rs)
PR #896
- macOS Strict TLS Improvements (#896)
What changed: Rust-backed Encrypt=Strict connections on macOS use Apple's Network.framework TLS engine.
Who benefits: Applications using Rust-backed Strict connections on supported macOS hosts.
Impact: Connections can negotiate TLS 1.3, with post-quantum key exchange offered on macOS 26 and later. Non-Strict connections retain their existing TLS path. (via mssql-python-rs)
PR #896
- Rust ODBC Table-Valued Parameters (#896)
What changed: Add table-valued parameter binding, materialized tables, and buffered data-at-execution support to the opt-in Rust ODBC provider.
Who benefits: Workloads using table-valued parameters through that provider.
Impact: The Rust ODBC provider can send structured table parameters, including supported NULL and streamed cell values. This does not change the default ODBC provider. (via mssql-python-rs)
PR #896
Bug Fixes
- Synapse Pooled Connection Close (#889)
What changed: Remove the unsupported READ COMMITTED reset from the autocommit-on pool-return rollback batch.
Who benefits: Applications using pooled connections to Azure Synapse dedicated SQL pools.
Impact: Closing a connection no longer fails because that cleanup batch attempts an unsupported isolation-level reset.
- Explicit Pooled Checkout Timeouts (#897)
What changed: Pooled checkout respects an explicit positive connection timeout when it is shorter than the login-derived validation timeout, then restores the original value after successful validation.
Who benefits: Applications that configure a short connection timeout to bound stale pooled-socket checks.
Impact: Validation no longer replaces that explicit bound with a longer login-derived timeout.
- Arrow Reader Cross-Thread Shutdown (#892)
What changed: Coordinate close and cancellation with complete Arrow batch operations, and prevent stale readers from affecting subsequent cursor results.
Who benefits: Applications closing Arrow readers from another thread or reusing their parent cursor.
Impact: Shutdown avoids the idle-cancellation race while preserving unrelated errors and protecting later result sets.
- Correct Pyformat Placeholder Handling (#888)
What changed: Preserve placeholder-like text inside SQL literals, quoted or bracketed identifiers, and comments; handle escaped percent signs consistently.
Who benefits: Applications using pyformat SQL containing quoted text, comments, or escaped percent signs.
Impact: Conversion no longer rewrites those protected regions or creates mismatched parameter values for escaped placeholders.
- Rust-Backed Connection Reliability (#896)
What changed: Fix connection-scoped and pooled-checkout timeout handling, descriptor lifetime and prepared-plan invalidation races, prepared-handle cleanup after cancellation, isolation-change cursor preservation, and connection stack overflow on small stacks.
Who benefits: Applications exercising those connection and statement operations through Rust-backed paths.
Impact: Applicable timeout budgets are honored, valid cursor state is preserved, and affected lifetime, cleanup, and small-stack failures are avoided. (via mssql-python-rs)
PR #896
- Rust ODBC Streaming Order (#896)
What changed: Send data-at-execution values in their bound positions rather than moving them afte...
v1.17.0
mssql-python 1.17.0
This release makes bulk copy more reliable, improves connection-pool performance and recovery, corrects multi-result row counts, and restores PEP 249 Timestamp() compatibility.
Release Highlights
More Reliable Bulk Copy (#860, #875)
- What changed: Bulk copy now works reliably after package upgrades, handles UTF-8 text correctly, rejects unsupported destination names early, and preserves full SQL Server datetime precision.
- Who benefits: Applications using
bulkcopy()orbulkcopy_arrow(), especially after an upgrade or when loading Unicode and high-precision temporal data. - Impact: Fewer upgrade failures, correct Unicode values, clearer destination-name errors, and no silent loss of datetime precision.
PR #860 | PR #875 | GitHub Issues #855, #843, #849, #869 | Thanks Jhonatas2 and oscarrobertson for the contributions.
pip install --upgrade mssql-pythonView mssql-python 1.17.0 on PyPI
Enhancements
Faster Connection Pool Reuse (#820)
- What changed: Clean pooled connections can be returned and reused with less redundant cleanup work.
- Who benefits: Applications that frequently acquire and return pooled connections.
- Impact: Lower connection-reuse overhead while preserving transaction safety.
PR #820
Bug Fixes
Faster Recovery from Dead Pooled Connections (#859)
- What changed: Connection checkout stops waiting on an unresponsive pooled connection after the configured login timeout and opens a replacement.
- Who benefits: Applications using connection pooling across unreliable or interrupted network connections.
- Impact: Applications recover predictably instead of hanging for many minutes on a dead pooled connection.
Accurate nextset() Row Counts (#864)
- What changed:
Cursor.nextset()now refreshesrowcountfor each subsequent data-modification result and resets it for row-producing results. - Who benefits: Applications processing multi-statement batches, stored procedures, or T-SQL loops with multiple results.
- Impact: Each result reports its own affected-row count instead of retaining the count from the first statement.
PR #864 | GitHub Issue #863 | Thanks LP Bispo (@phelipelui) for the contribution.
PEP 249 Timestamp() Compatibility (#872)
- What changed: The
microsecondargument is optional and defaults to zero. - Who benefits: Applications using the standard six-argument DB-API
Timestamp(year, month, day, hour, minute, second)constructor. - Impact: PEP 249-compatible calls no longer fail with a missing-argument
TypeError.
PR #872 | GitHub Issue #871 | Thanks @austinaviv for the contribution.
v1.16.0
mssql-python 1.16.0
This release expands platform coverage with Python 3.15, first ever conda release, introduces a new opt-in mssql-odbc provider, improves row and fetch performance, strengthens native runtime packaging, and addresses connection, encoding, UDT, and bulk-copy reliability.
Release Highlights
Python 3.15 Support (#817)
- What changed: Added Python 3.15 wheels and validation across supported Windows, Linux, and macOS x64 and ARM64 platforms. The PyPI release includes 41 prebuilt wheels for supported Python 3.10 through 3.15 environments.
- Who benefits: Applications adopting Python 3.15.
- Impact: Users can move to Python 3.15 without waiting for driver support.
pip install --upgrade mssql-pythonView mssql-python 1.16.0 on PyPI
First Official Conda Release
Version 1.16.0 marks the first official Conda release of the Microsoft Python Driver for SQL Server.
conda install -c microsoft mssql-pythonThe Conda distribution provides one environment-managed package containing the Python bindings and matching native runtimes. Conda selects the compatible build for supported Windows, Linux, and macOS x64 and ARM64 environments, and manages installation and upgrades without mixing pip-managed companion packages into the environment.
View mssql-python on Anaconda.org
New Opt-In mssql-odbc Provider (#730, #804)
- What changed: Added the Rust-based
mssql-odbcprovider through the version-matchedmssql-python-rsruntime. Enable it before the first connection usingMSSQL_PYTHON_NATIVE_PROVIDER=mssql-odbcormssql_python.native_provider = "mssql-odbc". - Who benefits: Applications evaluating or adopting the Rust-based ODBC provider.
- Impact: Users can opt in without changing existing applications; Microsoft ODBC Driver 18 (
msodbcsql18) remains the default.
Enhancements
Dictionary-Style Row Access (#613)
- What changed: Added a read-only
row._mappingview with dictionary conversion and stable column metadata. - Who benefits: Applications that need mapping semantics for fetched rows.
- Impact: Rows integrate with mapping-based code without manually combining values with
cursor.description(GitHub Issue #606).
Separately Packaged Rust Runtime (#768)
- What changed:
mssql-pythonnow installs its Rust runtime through the version-matchedmssql-python-rspackage instead of embedding those files in the main wheel. - Who benefits: Applications using bulk copy and other Rust-backed functionality.
- Impact: Runtime updates can ship through their own platform wheels while remaining exactly aligned with the Python bindings.
Stable-ABI Rust Runtime Wheels (#804)
- What changed: Adopted
mssql-python-rs0.3.0 and its CPython stable-ABI wheels for Python 3.10 and newer. - Who benefits: Users installing the Rust runtime across supported Python versions and platforms.
- Impact: One wheel per OS and architecture now serves multiple supported Python versions.
Updated ODBC Runtime Package (#798, #807)
- What changed: Updated to
mssql-python-odbc==18.6.2.2, separating Linux wheel contents by libc family while retaining the same ODBC Driver 18.6 binaries. - Who benefits: Linux users on glibc-based distributions or Alpine/musl.
- Impact: Each environment receives only its matching ODBC runtime payload.
Faster Row Construction and Batch Fetching (#558)
- What changed: Moved eligible Row construction into the native fetch path and reduced repeated cursor bookkeeping.
- Who benefits: Applications using
fetchone(),fetchmany(), orfetchall(). - Impact: Fetch workloads spend less time in Python-side Row initialization while preserving converters and diagnostics.
Faster Temporal Fetch Conversion (#795)
- What changed: DATE, TIME, and TIMESTAMP values now use checked CPython constructors.
- Who benefits: Applications fetching large temporal result sets.
- Impact: Temporal conversion requires less Python object-construction overhead while preserving existing values and exceptions.
Reusable Result-Set Metadata (#796)
- What changed: Stable native column metadata is retained for the current result set and invalidated when the result changes.
- Who benefits: Applications fetching many rows from result sets with stable column types.
- Impact: Fetch paths avoid repeated column descriptions while public metadata and
sql_variantbehavior remain current.
Reduced Fetch Diagnostic Overhead (#809)
- What changed: Fetch diagnostics are captured while ODBC records are valid and reused instead of being rescanned after clean fetches.
- Who benefits: Applications that perform many fetch calls.
- Impact: Clean fetches perform less repeated diagnostic work without changing warning or error propagation.
Faster Integer Row Indexing (#822)
- What changed: Exact integer indexes use a direct
Row.__getitem__fast path. - Who benefits: Applications that frequently access Row values by position.
- Impact: Integer lookup avoids unnecessary type dispatch while preserving behavior for booleans, subclasses, slices, and column names.
Lower fetchval() Logging Overhead (#823)
- What changed:
fetchval()checks whether debug logging is enabled before dispatching debug messages. - Who benefits: Applications calling
fetchval()with debug logging disabled. - Impact: Scalar fetches avoid unnecessary logging calls while preserving return values and row-consumption behavior.
Bug Fixes
Reliable Windows Shutdown (#783)
- What changed: Prevented the static ODBC environment handle from being released after Python finalization.
- Who benefits: Windows applications using pooled or nonpooled connections.
- Impact: Process shutdown no longer risks a late ODBC environment access violation.
Preserved Leading BOM-Like Characters (#793)
- What changed: Bounded UTF-16 fetches now treat leading U+FEFF and U+FFFE code points as payload instead of byte-order markers.
- Who benefits: Applications storing text that begins with BOM-shaped Unicode characters.
- Impact: Fetch operations return the complete bounded text value across supported platforms (GitHub Issue #794).
Clean Pooled Connection State (#777)
- What changed: Physical connections are rolled back and restored to autocommit before returning to the pool.
- Who benefits: Applications that reuse pooled connections after commits, rollbacks, or connection close.
- Impact: Idle sessions no longer retain empty transactions, and connections that cannot be sanitized are discarded (GitHub Issue #754).
Safe Native Logging of Dynamic Metadata (#791)
- What changed: Dynamic native log values, including server-controlled Arrow column metadata, are passed through literal format strings.
- Who benefits: Applications that enable native driver logging.
- Impact: Dynamic metadata cannot be interpreted as a native printf-style format directive.
UDT Parameter Binding (#818)
- What changed: SQL Server UDT parameter identities are resolved through
SQLDescribeParambefore scalar or array binding. - Who benefits: Applications binding spatial or other UDT values, including typed NULLs and reused statements.
- Impact: UDT parameters receive the required metadata without adding a new public API (GitHub Issue #816).
Visible Unsupported Encoding Requests (#828)
- What changed: Valid
setencoding()requests that cannot be applied now emitUserWarninginstead of being silently ignored. - Who benefits: Applications requesting
SQL_CHAR, UTF-16BE, or another unsupported binding configuration. - Impact: Callers can detect that the effective encoding remains unchanged while supported defaults continue without warnings (GitHub Issue #825).
Bounded Bulk Copy Timeouts (#804)
- What changed: Positive sub-second bulk-copy timeouts are rounded to one second instead of being truncated to an unlimited timeout.
- Who benefits: Applications configuring short bulk-copy timeouts.
- Impact: A positive timeout remains bounded rather than silently becoming infinite. Rust source: microsoft/mssql-rs#374. Thanks Lakshay Chauhan (@nos1dot618) for the contribution.
Safe Bulk Copy Identifiers (#804)
- What changed: Bulk-copy destinations, columns, and collations are parsed, quoted, escaped, and validated consistently.
- Who benefits: Applications using multipart names, temporary tables, custom metadata, or identifiers that require quoting.
- Impact: Valid identifiers are handled safely, while malformed components and collation tokens fail with a usage error. Rust source: microsoft/mssql-rs#550.
v1.15.0
Enhancements
• Faster setinputsizes() Execution (#736)
What changed: Routed setinputsizes() parameter handling through the native C++ execution pipeline.
Who benefits: Applications with wide, batched, or frequently executed parameterized statements.
Impact: These workloads spend less time in Python-side parameter processing.
PR #736
• memoryview Support in Binary() (#741)
What changed: Extended Binary() to accept memoryview objects as binary inputs.
Who benefits: Applications working with zero-copy views and other buffer-protocol data sources.
Impact: Binary values can be passed without first converting a memoryview to bytes.
PR #741
• Module-Level SQL Server Type Constants (#764)
What changed: Exposed SQL Server-specific type constants directly from the mssql_python module.
Who benefits: Developers using SQL Server type metadata and parameter declarations.
Impact: Type constants are easier to discover and access through the public package API.
PR #764
Bug Fixes
• Concurrent Logging No Longer Deadlocks (#678)
What changed: Corrected GIL and mutex lock ordering in native logging paths used concurrently by multiple threads.
Who benefits: Multithreaded applications with driver logging enabled.
Impact: Concurrent logging no longer risks hanging the process.
PR #678
• Correct Rust Core in Windows ARM64 Wheels (#737)
What changed: Windows ARM64 wheels now vendor the matching ARM64 mssql_py_core binary.
Who benefits: Windows ARM64 users, especially applications using bulk copy.
Impact: Installed wheels contain architecture-compatible native components and can use bulk copy correctly.
PR #737
• Reliable Package-Local DLL Loading on Windows (#735)
What changed: Bundled Windows driver and authentication DLLs are loaded from package-local directories.
Who benefits: Windows applications deployed in environments with varying DLL search paths.
Impact: Native dependencies resolve reliably without relying on process-wide search-path configuration.
PR #735
• Consistent Decimal Parameter Binding (#742)
What changed: Decimal parameters are now bound as SQL_NUMERIC regardless of their runtime value.
Who benefits: Applications that send decimal values through parameterized queries or batches.
Impact: Decimal parameter typing remains stable across values and execution paths.
PR #742
• ODBC 3.x Parameter Types (#758)
What changed: Replaced obsolete ODBC 2.x parameter type identifiers with their ODBC 3.x equivalents.
Who benefits: Applications using typed parameters across current SQL Server driver configurations.
Impact: Parameter binding follows the current ODBC standard and avoids legacy type mismatches.
PR #758 - Thanks @Theekshna for the contribution!
• Database Name Metadata Is Decoded (#771)
What changed: Added decoding for the value returned by Connection.getinfo(SQL_DATABASE_NAME).
Who benefits: Applications that inspect the active database through connection metadata.
Impact: Database names are returned as correct Python text values.
PR #771
• Mixed Cursor Cleanup No Longer Crashes at Shutdown (#772)
What changed: Corrected native cleanup ordering for connections containing cursors in mixed lifecycle states.
Who benefits: Applications that create multiple cursors and allow some cursor cleanup to occur during shutdown.
Impact: Process shutdown completes without a native crash from mixed cursor cleanup.
PR #772
v1.14.0
Enhancements
• Faster Parameter Detection and Execution (#549)
What changed: Parameter type detection and binding now run in a single native C++ pipeline, removing per-parameter Python and pybind11 overhead from the standard execute() path.
Who benefits: Applications with wide parameterized statements and batched execute workloads.
Impact: Parameter detection is approximately 60 times faster; benchmarks showed about 50% faster execution for statements with 50 or more parameters and 1.5-1.6 times higher end-to-end throughput in representative bulk insert scenarios.
Bug Fixes
• Bulk Copy Accepts timeout=0 (#698)
What changed: bulkcopy() now passes a zero timeout through as an unlimited timeout, matching the BCP API contract, while still rejecting negative, non-integer, and boolean values.
Who benefits: Users who explicitly disable bulk-copy timeouts with timeout=0.
Impact: The documented no-timeout behavior now works instead of raising a validation error.
• Arrow Reader Fetch Exceptions Are Preserved (#718)
What changed: Defensive Arrow cursor cleanup now checks cursor state before cleanup and no longer raises a secondary error that replaces the original fetch exception.
Who benefits: Applications that consume Arrow result batches and encounter a fetch failure.
Impact: Callers now receive the actual fetch error, making failures accurate and diagnosable.
• Decimal Conversion Errors No Longer Expose Parameter Values (#719)
What changed: executemany() Decimal conversion failures now report only row index, column index, and value type. Potentially value-bearing exception causes are suppressed so sensitive data cannot leak through chained tracebacks.
Who benefits: Applications that log or export database exceptions to monitoring and APM systems.
Impact: Invalid Decimal parameters remain diagnosable without exposing parameter rows, personally identifiable information, or secrets.
PR #719
• Arrow View Types Work in Bulk Copy (#729)
What changed: The bundled mssql_py_core 0.1.9 adds support for Arrow View types, with end-to-end coverage for Polars string_view columns passed directly through the Arrow C Data Interface.
Who benefits: Polars users and other Arrow producers that export variable-length View arrays to bulkcopy_arrow().
Impact: String View values and NULLs now round-trip correctly without requiring conversion through DataFrame.to_arrow().
PR #729 | GitHub Issue #708 - Thanks @gargsaumya for the contribution! (via
mssql_py_core)
• connect(timeout=) Sets the Login Timeout (#728)
What changed: The constructor timeout is now applied as SQL_ATTR_LOGIN_TIMEOUT instead of a per-statement query timeout; query timeout remains independently configurable through Connection.timeout, and both entry points validate values consistently.
Who benefits: Users who need connection attempts to fail within a predictable time while allowing long-running queries.
Impact: connect(timeout=N) now bounds login attempts as documented and no longer aborts queries after N seconds.
• Windows Extension Loading Uses Interpreter Architecture (#727)
What changed: On Windows, the native extension loader now derives architecture from the running Python interpreter instead of the host CPU and emits fallback notices as warnings rather than writing to stdout.
Who benefits: Users running x64 Python on Windows ARM64 hosts and tools that require clean stdout during import.
Impact: The loader selects the win_amd64 extension directly, avoiding repeated fallback loading and stray import output.
PR #727 | GitHub Issue #726 - Thanks @Om-singhaI for the contribution!
v1.13.0
Enhancements
• ODBC Driver Now Ships Exclusively via mssql-python-odbc — Phase 2 Complete (#693)
What changed: The bundled libs/ fallback introduced in v1.12.0 has been removed. mssql-python now hard-depends on mssql-python-odbc==18.6.2.1 (declared in install_requires); the native loader imports mssql_python_odbc at startup and resolves the driver / libs base directory from there. There is no in-wheel fallback anymore. pip install mssql-python continues to Just Work — the companion package is pulled transparently.
Who benefits: Users who wanted to pin or update driver binaries independently of the Python driver, redistributors who wanted a slimmer mssql-python wheel, and CI/reproducible builds that could not tolerate two distributions co-owning the libs/ directory.
Impact: Wheels are smaller and driver binaries are managed as an ordinary versioned dependency. If you install mssql-python from a private index or with --no-deps, install mssql-python-odbc==18.6.2.1 alongside it explicitly.
PR #693
• Apache Arrow Bulk Copy (#665)
What changed: New Cursor.bulkcopy_arrow(table_name, source) method for bulk loading directly from Apache Arrow sources — pyarrow.Table, pyarrow.RecordBatch, RecordBatchReader, or any object exposing the Arrow C Data Interface. The Arrow path skips the Python row materialization that classic bulkcopy() does, so ingestion of Arrow-native data is significantly faster. The classic bulkcopy() method now raises TypeError when given Arrow-shaped input and steers users to the new method. Connection context and Azure AD authentication were refactored into a shared _build_pycore_context() helper so bulkcopy and bulkcopy_arrow share identical auth handling.
Who benefits: Users with Arrow-native pipelines (Polars, DuckDB, Parquet, cross-language ETL) ingesting into SQL Server, and anyone who previously converted Arrow tables to lists of tuples just to call bulkcopy().
Impact: A fast, first-class Arrow ingestion API without leaving Arrow memory.
PR #665
• token_provider= Parameter for Azure Identity Credentials (#603)
What changed: connect() and the Connection class now accept a token_provider parameter — any object with a .get_token(scope) method. This includes every credential in azure-identity (DefaultAzureCredential, AzureCliCredential, ManagedIdentityCredential, ClientSecretCredential, …) as well as custom credential objects. Bulk copy operations re-acquire a fresh token from the provider per operation. token_provider is mutually exclusive with Authentication= in the connection string and with pre-acquired tokens in attrs_before. Only the Azure commercial cloud scope is supported via this path. A TokenProvider protocol type is exported for typing.
Who benefits: Applications that already build their credential chain with azure-identity (very common for Azure-hosted services) and want a single credential object to authenticate to SQL Server without hand-rolling ODBC SQL_COPT_SS_ACCESS_TOKEN handling.
Impact: Idiomatic Azure SDK auth for mssql-python.
• Identity-Aware Connection Pooling with Token-Expiry Refresh (#660)
What changed: The connection pool used to key only on the connection string, so two callers hitting the same server with different Entra identities collided onto one pool — a connection authenticated as user A could be handed to user B. The pool now keys on security context: for non-token auth (SQL / trusted / Service Principal / Windows-interactive) the key is unchanged; for token-based auth the key becomes connStr + "\x00" + <identity discriminator> where the discriminator is msi:<client_id> / msi:system for managed identity, acct:<home_account_id> for interactive/device-code, and tok:<sha256(token)> for DefaultAzureCredential / raw tokens. Two secondary fixes: token acquisition is now deferred to pool-misses (previously a token was acquired on every connect, even on pool hits), and pooled connections whose token is within 5 minutes of expiry are refreshed by minting a new token, byte-comparing against the pooled one, and reopening the slot when they differ. Idle identity-pools are reclaimed lazily to avoid leaks.
Who benefits: Multi-tenant services and any application that authenticates with more than one Entra identity in the same process.
Impact: Cross-identity connection leaks are prevented and token overhead on pool hits is eliminated.
Bug Fixes
• Silent Zero-Row executemany Batches on Late NULLs (#702)
What changed: Fixed the numeric array parameter binding paths (TINYINT, SMALLINT, INT, FLOAT) which allocated the ODBC indicator array only after encountering the first NULL. Earlier rows then contained uninitialized indicator slots that ODBC could interpret as data-at-execution markers, silently inserting zero rows for the entire batch without raising an exception. Indicators are now initialized for every fixed-width numeric parameter before array execution. Reproduction rate dropped from 209/300 anomalous batches to 0/300.
Who benefits: Any code path that uses executemany with mixed non-NULL / NULL numeric values.
Impact: Batches now insert every row deterministically.
• SQL_WVARCHAR Output Converter Applied as Catch-All to Non-String Columns (#692)
What changed: Cursor._build_converter_map used to fall back to the converter registered for SQL_WVARCHAR for any column that had no direct type-keyed converter, so registering a single SQL_WVARCHAR converter mangled INT / DECIMAL / DATE values as well. The optimized apply path also swallowed the resulting AttributeError, hiding the misbehavior in tests. The fallback is now gated on the column's mapped Python type being str or bytes, mirroring the guard already present in Row._apply_output_converters.
Who benefits: Users who register add_output_converter(SQL_WVARCHAR, ...) for legitimate string decoding without wanting it applied to numeric or date columns.
Impact: Output converters registered for SQL_WVARCHAR behave consistently with the documented and pyodbc-compatible semantics.
• Integer-Keyed Output Converters Silently Never Fired (#690)
What changed: Connection.add_output_converter(sqltype, func) is documented (and pyodbc accepts) to take an integer ODBC SQL type code as the key — for example SQL_DECIMAL, SQL_INTEGER. However, Cursor._build_converter_map() dispatched on the mapped Python type in cursor.description[i][1], so integer-keyed converters were stored but never invoked. The raw ODBC SQL type code is now captured in self._column_sql_types, and _build_converter_map dispatches in pyodbc-compatible order: (1) integer SQL type code, (2) Python type in description[i][1], (3) the legacy WVARCHAR catch-all. Integer keys use exact ODBC type matching, so SQL_DECIMAL and SQL_NUMERIC are distinct. Catalog metadata result sets (columns(), tables(), …) also build the converter map now.
Who benefits: Users migrating from pyodbc who register converters by SQL type code and expect them to fire, and anyone who needs distinct handling for SQL_DECIMAL vs SQL_NUMERIC or exact ODBC type dispatch.
Impact: add_output_converter now matches its documentation and pyodbc's behavior.
• RecordBatchReader.Close() for Arrow Result Sets (#644)
What changed: Cursor.arrow_reader() previously returned a raw pyarrow.RecordBatchReader, so closing the reader did not release the server-side cursor and the parent Cursor was left in an inconsistent state. It now returns an _ArrowReader wrapper whose .close() runs an 8-step cleanup: stops fetching, releases the server-side cursor, resets cursor state, and is idempotent. The parent Cursor remains usable after the reader is closed, and the wrapper supports use as a context manager.
Who benefits: Applications that fetch large result sets via Arrow and close early (streaming pipelines, request-scoped queries, long-running services that reuse cursors).
Impact: Predictable, prompt cleanup of server-side resources on Arrow reader close.
• AttributeError in Cursor.__del__ on Partially-Initialized Cursor (#646)
What changed: If Cursor.__init__ raised before self.closed and self.hstmt were set, garbage collection later called __del__ and hit an AttributeError that surfaced as an unraisable exception. `init...
v1.12.0
Enhancements
• Standalone mssql-python-odbc Package for ODBC Driver Binaries (#663, #687)
What changed: The ODBC driver binaries that mssql-python needs at runtime are now also published as a separate, pure-data companion package called mssql-python-odbc (import name mssql_python_odbc, currently pinned to version 18.6.2). mssql-python declares mssql-python-odbc==18.6.2 in install_requires, so pip install mssql-python transparently pulls the driver package alongside it. The native loader prefers the external mssql_python_odbc package when it is present, and falls back to the ODBC driver binaries still bundled inside the mssql-python wheel when it is not — so existing installations keep working with no code changes. The fallback is GIL-safe and Alpine/musl-safe.
Who benefits: Users who want to keep driver binaries pinned or updated independently of the Python driver code, redistributors who want a slimmer mssql-python wheel over time, and anyone who was hitting duplicate-ownership issues from bundled ODBC files.
Impact: The Phase-2 split ships without a breaking change. In a future major release (v2.0.0) the bundled libs/ tree will be removed and mssql-python-odbc will become a hard dependency.
Bug Fixes
• Bulk Copy Connection Timeout Not Honored (#650)
What changed: cursor.bulkcopy() opens a separate connection through mssql_py_core, which previously defaulted to a hardcoded 15-second connect timeout with no way to override it from Python. The cursor's query timeout (set via connect(timeout=X)) is now forwarded into mssql_py_core's connect_timeout when it is set. timeout=0 is preserved as "no override" and leaves mssql_py_core on its 15s default. The cursor's timeout snapshot at the time of the bulkcopy() call is what is used — later changes to the parent connection do not affect an in-flight bulk copy.
Who benefits: Applications that call bulkcopy() against slow, throttled, or high-latency SQL Server endpoints (for example over VPN or in cross-region scenarios) and need a longer connect timeout, or that need to fail fast with a shorter one.
Impact: bulkcopy() now honors the same connect timeout as the rest of the driver.
• Bulk Copy Fails on Custom CLR UDT Columns (via mssql_py_core) (#688)
What changed: cursor.bulkcopy() into a column whose type is a custom, assembly-registered CLR UDT (any UDT other than the built-in geography / geometry / hierarchyid) previously failed with Protocol Error: Unsupported TDS type for bulk copy: 0xF0, because the wire path in the native core had no handler for the UDT (0xF0) type token when writing COLMETADATA. The Rust core now maps UDT columns to varbinary(max) on the wire and streams the supplied bytes as the UDT's serialized form (its IBinarySerialize payload), matching how pyodbc and python-tds load UDT columns. SQL Server materializes the UDT on insert. Delivered via the mssql_py_core 0.1.6 → 0.1.7 bump.
Who benefits: Users who bulk-load rows into tables with custom CLR UDT columns.
Impact: Bulk copy into custom CLR UDT columns now succeeds when the supplied values are the UDT's serialized bytes.
v1.11.0
Bug Fixes
• SSH-tunnel / in-process forwarder deadlock (#604)
What changed: The driver now releases the GIL around blocking ODBC network round-trips that previously held it — the teardown path (SQLFreeHandle / SQLFreeStmt(SQL_CLOSE) when closing a statement with an open server-side cursor) and the SQLDescribeParam call issued for parametrized queries containing a None argument. The teardown release is guarded against interpreter finalization to stay safe during shutdown.
Who benefits: Users whose connection is routed through an in-process Python TCP forwarder (SSH-tunnel-style setups), where a GIL held across a blocking network syscall wedged the forwarder thread.
Impact: conn.close() / cursor.close() after a parametrized query, and parametrized queries with None values, no longer deadlock the interpreter.
• BINARY/VARBINARY NULL parameters in temp tables and table variables (#654)
What changed: Unknown NULL parameter types are now proactively resolved before any parameter is bound (for both single and batch execution paths). When SQLDescribeParam fails and the type falls back to SQL_VARCHAR, the driver emits a Python warning with concrete cursor.setinputsizes() guidance for binary columns.
Who benefits: Users inserting NULL values into BINARY / VARBINARY columns of temp tables or table variables, which previously hit driver errors or SQL Server implicit-conversion failures.
Impact: NULL binary parameters bind reliably, and when automatic resolution is not possible users get actionable guidance instead of an opaque error.
• Context manager transaction semantics (#639)
What changed: The Connection context manager (__exit__) now implements commit-on-success / rollback-on-exception semantics. With autocommit=False, a clean exit commits the transaction and an exception rolls it back; with autocommit=True behavior is unchanged. The connection is always closed on exit.
Who benefits: Users relying on with connection: blocks who previously saw every block roll back — because __exit__ only called close() regardless of how the block exited.
Impact: with blocks now persist committed work on clean exit and safely roll back on error, matching the documented behavior.
• macOS Apple Silicon import failure (#661)
What changed: configure_dylibs.sh now rewrites the bundled ODBC dylib dependencies to @loader_path for every architecture shipped in the universal2 wheel (arm64 and x86_64), not just the build host's arch. The committed arm64 and x86_64 dylibs were also re-fixed.
Who benefits: Apple Silicon users on a clean machine, where the arm64 driver previously pointed at an absolute Homebrew path (/opt/homebrew/lib/libodbcinst.2.dylib) that is absent until brew install unixodbc is run. Regressed in 1.8.0.
Impact: import mssql_python works out of the box on Apple Silicon with no separate unixODBC install.
• Service Principal bulk copy freeze (#666)
What changed: Fixed a GIL-deadlock in the Rust core that froze bulk copy when authenticating with a service principal. The fix lands in mssql_py_core and is picked up by bumping the bundled dependency from 0.1.5 to 0.1.6. (via mssql_py_core)
Who benefits: Users running bulkcopy with Authentication=ActiveDirectoryServicePrincipal, which previously froze mid-operation.
Impact: Service principal bulk copy completes without freezing.
v1.10.0
Enhancements
• Active Directory Service Principal support for Bulk Copy (#576)
What changed: bulkcopy now supports Authentication=ActiveDirectoryServicePrincipal. Because the tenant ID is only discoverable from the STS URL the server returns mid-handshake, the driver registers a token-provider callback (invoked with spn, sts_url, auth_method) that parses the tenant, builds a ClientSecretCredential, and returns a UTF-16LE encoded JWT.
Who benefits: Users who authenticate with a service principal (client ID + client secret) and need to perform bulk inserts against Azure SQL / SQL Server.
Impact: Service principal credentials now work for bulk copy operations, resolving the previous "Authentication method 'ActiveDirectoryServicePrincipal' is not supported. No token provider was registered for this method." error.
Bug Fixes
• Non-ASCII VARCHAR data in the Arrow fetch path (#575)
What changed: The Arrow fetch path now requests SQL_CHAR data as SQL_C_WCHAR (UTF-16LE) instead of relying on the narrow character path. This guarantees correct decoding regardless of encoding settings, locale, or operating system, with no significant performance impact.
Who benefits: Users fetching VARCHAR/CHAR columns containing non-ASCII data through the Arrow interface.
Impact: Arrow fetch methods now always return correct string data independent of the host environment.
PR #575 | GitHub Issue #553 - Thanks @ffelixg for the contribution!
• Bulk load connection timeouts (#641)
What changed: Fixed connection timeouts that occurred during bulk load operations. The fix lands in the Rust core and is picked up by bumping the bundled mssql_py_core dependency from 0.1.4 to 0.1.5. (via mssql_py_core)
Who benefits: Users running bulk load operations that previously hit intermittent connection timeouts.
Impact: Bulk load operations complete reliably without spurious connection timeouts.