github microsoft/mssql-python v1.8.0

3 hours ago

Release Notes - Version 1.8.0

Enhancements

ActiveDirectoryMSI Support for Bulk Copy (#573)

What changed: Added Authentication=ActiveDirectoryMSI support to cursor.bulkcopy(), enabling both system-assigned (ManagedIdentityCredential()) and user-assigned (ManagedIdentityCredential(client_id=UID)) managed identity authentication. Credential kwargs are now threaded through the token acquisition path and persisted on the Connection to survive the bulk copy fresh-token flow.
Who benefits: Users running bulk copy operations from Azure-hosted services (VMs, App Service, Functions, AKS) that authenticate via Managed Identity.
Impact: Bulk copy now works with MSI authentication without workarounds. Previously only Default, DeviceCode, and Interactive auth methods were supported for bulk copy.

PR #573 | GitHub Issue #534

Row String-Key Indexing (#589)

What changed: Row.__getitem__ now supports accessing values by column name as a string key (e.g., row["col"]), in addition to existing integer index and attribute access. Case-insensitive lookup is supported when the cursor's lowercase attribute is enabled.
Who benefits: All users who prefer dictionary-style access to result rows.
Impact: More intuitive row access patterns without needing to track column ordinal positions.

PR #589 | GitHub Issue #582

Bundled ODBC Driver Upgrade (#569)

What changed: Updated the bundled Microsoft ODBC Driver for SQL Server from 18.5.1.1 to 18.6.2.1, picking up the latest fixes and improvements from the ODBC driver team.
Who benefits: All users — benefits from the latest ODBC driver stability and compatibility improvements.
Impact: Improved compatibility and stability from the latest ODBC driver release.

PR #569


Bug Fixes

Deferred Connect-Attribute Use-After-Free (#596)

What changed: Fixed a use-after-free in Connection.setAttribute where deferred ODBC attributes (e.g., SQL_COPT_SS_ACCESS_TOKEN) were copied to stack-local buffers that were freed before the driver dereferenced them during SQLDriverConnect. Values are now stored in Connection-owned member buffers that remain valid for the lifetime of the connection.
Who benefits: Users authenticating with access tokens (Entra ID / AAD), especially on macOS arm64 and Azure SQL.
Impact: Eliminates SIGBUS crashes on macOS arm64, ProgrammingError: Authentication token is missing on Windows, and OperationalError: Communication link failure on Azure SQL when using token-based authentication.

PR #596 | GitHub Issue #594

Connection String Parsed Multiple Times in Auth Path (#590)

What changed: Refactored authentication handling from string-based to dictionary-based parameter processing, eliminating redundant connection string parsing passes. _construct_connection_string now returns a normalized parameter dictionary alongside the string, removing the need for downstream re-parsing and ensuring robust sanitization of sensitive parameters before ODBC handoff.
Who benefits: All users using Entra ID / AAD authentication methods.
Impact: More reliable authentication with reduced overhead and cleaner sensitive-parameter sanitization.

PR #590 | GitHub Issue #580

executemany Type Annotation Regression (#586)

What changed: Changed the seq_of_parameters type from invariant List[Sequence[Any]] to covariant Sequence[Sequence[Any]], fixing a mypy rejection of valid list[tuple[...]] arguments introduced in v1.6.0's dual paramstyle support. Runtime behaviour is unchanged.
Who benefits: Users running mypy or other static type checkers on code that calls Cursor.executemany.
Impact: executemany now correctly accepts list[tuple[...]], list[list[...]], and other sequence-of-sequences under strict type checking, matching PEP 249.

PR #586 | GitHub Issue #572

Don't miss a new mssql-python release

NewReleases is sending notifications on new releases.