Skip to content

Commit ec764d1

Browse files
committed
Merged PR 6131: SYNC: Github main to ADO main
Sync GH to ADO ---- #### AI description (iteration 1) #### PR Classification This PR syncs updates from GitHub main into the ADO main branch, incorporating extensive test additions, pipeline enhancements, and core code improvements. #### PR Summary The PR merges comprehensive changes including new tests for cursor/connection and global settings, updated build and PR-validation pipeline configurations for cross-platform wheel builds, and enhancements to the connection and cursor modules (e.g. context manager, execute methods, output converters). - **`tests/`**: Added and updated numerous tests in files such as `test_003_connection.py` and `test_001_globals.py` to cover execute methods, batch execution, timeout handling, encoding/decoding APIs, exception attributes, and thread‐safety. - **`eng/pipelines/build-whl-pipeline.yml` & `pr-validation-pipeline.yml`**: Revised YAML pipeline definitions to support manylinux, musllinux, Alpine (both x86_64 and ARM64), and improved artifact collection and test reporting. - **`mssql_python/cursor.py`**: Enhanced cursor functionality with refined context manager support, fetch methods, scrolling, and error handling. - **`mssql_python/connection.py`**: Updated connection API including new execute() convenience methods, output converter management (add/get/remove/clear), setencoding/getencoding and setdecoding/getdecoding methods, and timeout support. - **Removed file**: Deleted the obsolete `/mssql_python/testing_ddbc_bindings.py` as its functionality has been integrated into the core modules. <!-- GitOpsUserAgent=GitOps.Apps.Server.pullrequestcopilot --> Related work items: #38881
1 parent 4957db1 commit ec764d1

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

46 files changed

+22868
-2224
lines changed

.coveragerc

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
11
[run]
22
omit =
3-
mssql_python/testing_ddbc_bindings.py
3+
main.py
4+
setup.py
5+
bcp_options.py
46
tests/*
57

68
[report]

.github/workflows/pr-code-coverage.yml

Lines changed: 491 additions & 0 deletions
Large diffs are not rendered by default.

.github/workflows/pr-format-check.yml

Lines changed: 26 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -57,9 +57,9 @@ jobs:
5757
// Extract the summary content
5858
const summaryContent = summaryMatch[1];
5959
60-
// Remove all HTML comments including the template placeholder
60+
// Remove all HTML comments including unclosed ones (template placeholders)
6161
const contentWithoutComments =
62-
summaryContent.replace(/<!--[\s\S]*?-->/g, '');
62+
summaryContent.replace(/<!--[\s\S]*?(?:-->|$)/g, '');
6363
6464
// Remove whitespace and check if there's actual text content
6565
const trimmedContent = contentWithoutComments.trim();
@@ -94,24 +94,35 @@ jobs:
9494
labelToAdd = 'pr-size: large';
9595
}
9696
97-
// Remove existing size labels if any
97+
// Get existing labels
9898
const existingLabels = pr.labels.map(l => l.name);
9999
const sizeLabels = ['pr-size: small', 'pr-size: medium', 'pr-size: large'];
100-
for (const label of existingLabels) {
101-
if (sizeLabels.includes(label)) {
100+
101+
// Find current size label (if any)
102+
const currentSizeLabel = existingLabels.find(label => sizeLabels.includes(label));
103+
104+
// Only make changes if the label needs to be updated
105+
if (currentSizeLabel !== labelToAdd) {
106+
console.log(`Current size label: ${currentSizeLabel || 'none'}`);
107+
console.log(`Required size label: ${labelToAdd} (Total changes: ${totalChanges})`);
108+
109+
// Remove existing size label if different from required
110+
if (currentSizeLabel) {
111+
console.log(`Removing outdated label: ${currentSizeLabel}`);
102112
await github.rest.issues.removeLabel({
103113
...context.repo,
104114
issue_number: pr.number,
105-
name: label,
115+
name: currentSizeLabel,
106116
});
107117
}
108-
}
109118
110-
// Add new size label
111-
await github.rest.issues.addLabels({
112-
...context.repo,
113-
issue_number: pr.number,
114-
labels: [labelToAdd],
115-
});
116-
117-
console.log(`Added label: ${labelToAdd} (Total changes: ${totalChanges})`);
119+
// Add new size label
120+
console.log(`Adding new label: ${labelToAdd}`);
121+
await github.rest.issues.addLabels({
122+
...context.repo,
123+
issue_number: pr.number,
124+
labels: [labelToAdd],
125+
});
126+
} else {
127+
console.log(`Label already correct: ${labelToAdd} (Total changes: ${totalChanges}) - no changes needed`);
128+
}

.gitignore

Lines changed: 17 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,3 @@
1-
# Ignore all files in the pybind/build directory
2-
mssql_python/pybind/build/
3-
41
# Ignore pycache files and folders
52
__pycache__/
63
**/__pycache__/
@@ -23,6 +20,7 @@ test-*.xml
2320

2421
# Ignore the build & mssql_python.egg-info directories
2522
build/
23+
**/build/
2624
mssql_python.egg-info/
2725

2826
# Python bytecode
@@ -46,4 +44,19 @@ build/
4644
*.swp
4745

4846
# .DS_Store files
49-
.DS_Store
47+
.DS_Store
48+
49+
# wheel files
50+
*.whl
51+
*.tar.gz
52+
*.zip
53+
54+
# Dockerfiles and images (root only)
55+
/Dockerfile*
56+
/docker-compose.yml
57+
/docker-compose.override.yml
58+
/docker-compose.*.yml
59+
60+
# Virtual environments
61+
*venv*/
62+
**/*venv*/

PyPI_Description.md

Lines changed: 43 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,26 +1,55 @@
11
# mssql-python
22

3-
This is a new Python driver for Microsoft SQL Server currently in Alpha phase.
3+
mssql-python is a new first-party SQL Server driver for Python that has all of the benefits of a fresh start while preserving a familiar experience for developers.
4+
5+
## What makes mssql-python different?
6+
7+
### Powered by DDBC – Direct Database Connectivity
8+
9+
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.
10+
11+
At the heart of the driver is DDBC (Direct Database Connectivity) — a lightweight, high-performance C++ layer that replaces the platform’s Driver Manager.
12+
13+
Key Advantages:
14+
15+
- Provides a consistent, cross-platform backend that handles connections, statements, and memory directly.
16+
- Interfaces directly with the native SQL Server drivers.
17+
- Integrates with the same TDS core library that powers the ODBC driver.
18+
19+
### Why is this architecture important?
20+
21+
By simplifying the architecture, DDBC delivers:
22+
23+
- Consistency across platforms
24+
- Lower function call overhead
25+
- Zero external dependencies on Windows (`pip install mssql-python` is all you need)
26+
- Full control over connections, memory, and statement handling
27+
28+
### Built with PyBind11 + Modern C++ for Performance and Safety
29+
30+
To expose the DDBC engine to Python, mssql-python uses PyBind11 – a modern C++ binding library, instead of ctypes. With ctypes, every call between Python and the ODBC driver involved costly type conversions, manual pointer management, resulting in slow and potentially unsafe code.
31+
32+
PyBind11 provides:
33+
34+
- Native-speed execution with automatic type conversions
35+
- Memory-safe bindings
36+
- Clean and Pythonic API, while performance-critical logic remains in robust, maintainable C++.
437

538
## Public Preview Release
639

7-
We are making progress - The Public Preview of our driver is now available! This marks a significant milestone in our development journey. While we saw a few early adopters of our alpha release, we are introducing the following functionalities to support your applications in a more robust and reliable manner.
40+
We are currently in **Public Preview**.
841

9-
### What's Included:
42+
## What's new in v0.12.0
1043

11-
- Everything from previous releases
12-
- **Azure Active Directory Authentication:** New authentication module supporting Azure AD login options (ActiveDirectoryInteractive, ActiveDirectoryDeviceCode, ActiveDirectoryDefault) for secure and flexible cloud integration.
13-
- **Batch Execution Performance:** Refactored `executemany` for efficient bulk operations and improved C++ bindings for performance.
14-
- **Robust Logging System:** Overhauled logging with a singleton manager, sensitive data sanitization, and better exception handling.
15-
- **Improved Row Representation:** Enhanced output and debugging via updated `Row` object string and representation methods.
44+
- **Complex Data Type Support:** Added native support for DATETIMEOFFSET and UNIQUEIDENTIFIER data types with full round-trip handling, enabling seamless integration with Python's timezone-aware `datetime` objects and `uuid.UUID` types.
45+
- **Support for monetary or currency values data types:** Extended MONEY and SMALLMONEY support to `executemany` operations with proper NULL handling and decimal conversion for improved bulk financial data processing.
46+
- **Improved Database Metadata API:** Added `getinfo()` method with enhanced ODBC metadata retrieval, allowing users to query driver/data source information using ODBC info types.
47+
- **Data Processing Optimizations:** Removed aggressive datetime parsing to prevent incorrect type conversions and improve data integrity across diverse datetime formats and string data.
1648

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

19-
### What's Next:
20-
21-
As we continue to develop and refine the driver, you can expect regular updates that will introduce new features, 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 for the final release.
51+
If you have any feedback, questions or need support please mail us at mssql-python@microsoft.com.
2252

23-
### Stay Tuned:
53+
## What's Next
2454

25-
We appreciate your interest and support in this project. Stay tuned for more updates and enhancements as we work towards delivering a robust and fully-featured driver in coming months.
26-
Thank you for being a part of our journey!
55+
As we continue to develop and refine the driver, you can expect regular updates that will introduce new features, 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 ahead of General Availability.

README.md

Lines changed: 19 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -17,22 +17,37 @@ pip install mssql-python
1717
```
1818
**MacOS:** mssql-python can be installed with [pip](http://pypi.python.org/pypi/pip)
1919
```bash
20+
# For Mac, OpenSSL is a pre-requisite - skip if already present
2021
brew install openssl
2122
pip install mssql-python
2223
```
2324
**Linux:** mssql-python can be installed with [pip](http://pypi.python.org/pypi/pip)
2425
```bash
26+
# For Alpine
27+
apk add libtool krb5-libs krb5-dev
28+
29+
# For Debian/Ubuntu
30+
apt-get install -y libltdl7 libkrb5-3 libgssapi-krb5-2
31+
32+
# For RHEL
33+
dnf install -y libtool-ltdl krb5-libs
34+
35+
# For SUSE
36+
zypper install -y libltdl7 libkrb5-3 libgssapi-krb5-2
37+
38+
# For SUSE/openSUSE
39+
zypper install -y libltdl7
40+
2541
pip install mssql-python
2642
```
2743

2844
## Key Features
2945
### Supported Platforms
3046

31-
Windows, MacOS and Linux (manylinux2014 - Debian, Ubuntu & RHEL)
47+
Windows, MacOS and Linux (manylinux - Debian, Ubuntu, RHEL, SUSE (x64 only) & musllinux - Alpine)
3248

3349
> **Note:**
34-
> Support for additional Linux OSs (Alpine, SUSE Linux) will come soon
35-
>
50+
> SUSE Linux ARM64 is not supported by Microsoft ODBC Driver. Use x64 architecture for SUSE deployments.
3651
3752
### DBAPI v2.0 Compliance
3853

@@ -62,10 +77,7 @@ EntraID authentication is now fully supported on MacOS and Linux but with certai
6277
| ActiveDirectoryDeviceCode | ✅ Yes | ✅ Yes | Device code flow for authentication; suitable for environments without browser access |
6378
| ActiveDirectoryDefault | ✅ Yes | ✅ Yes | Uses default authentication method based on environment and configuration |
6479

65-
**NOTE**:
66-
- **Access Token**: the connection string **must not** contain `UID`, `PWD`, `Authentication`, or `Trusted_Connection` keywords.
67-
- **Device Code**: make sure to specify a `Connect Timeout` that provides enough time to go through the device code flow authentication process.
68-
- **Default**: Ensure you're authenticated via az login, or running within a managed identity-enabled environment.
80+
> For more information on Entra ID please refer this [document](https://github.com/microsoft/mssql-python/wiki/Microsoft-Entra-ID-support)
6981
7082
### Enhanced Pythonic Features
7183

0 commit comments

Comments
 (0)