Skip to content

Commit 7f2d80b

Browse files
committed
Merge branch 'bewithgaurav/publish_symbols' of https://github.com/microsoft/mssql-python into bewithgaurav/publish_symbols
2 parents 4421646 + 2d0265f commit 7f2d80b

29 files changed

Lines changed: 3030 additions & 414 deletions

.github/PULL_REQUEST_TEMPLATE.MD

Lines changed: 26 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,20 @@
1-
### ADO Work Item Reference
2-
<!-- Insert your ADO Work Item ID below (e.g. AB#37452) -->
1+
### Work Item / Issue Reference
2+
<!--
3+
IMPORTANT: Please follow the PR template guidelines below.
4+
For mssql-python maintainers: Insert your ADO Work Item ID below (e.g. AB#37452)
5+
For external contributors: Insert Github Issue number below (e.g. #149)
6+
Only one reference is required - either GitHub issue OR ADO Work Item.
7+
-->
8+
9+
<!-- mssql-python maintainers: ADO Work Item -->
310
> AB#<WORK_ITEM_ID>
11+
12+
<!-- External contributors: GitHub Issue -->
13+
> GitHub Issue: #<ISSUE_NUMBER>
14+
415
-------------------------------------------------------------------
516
### Summary
6-
<!-- Insert your Copilot Generated Summary below -->
17+
<!-- Insert your summary of changes below. Minimum 10 characters required. -->
718

819

920
<!--
@@ -29,4 +40,16 @@ REFACTOR: (short-description)
2940
3041
> For release related changes, without any feature changes
3142
RELEASE: #<RELEASE_VERSION> (short-description)
43+
44+
### Contribution Guidelines
45+
46+
External contributors:
47+
- Create a GitHub issue first: https://github.com/microsoft/mssql-python/issues/new
48+
- Link the GitHub issue in the "GitHub Issue" section above
49+
- Follow the PR title format and provide a meaningful summary
50+
51+
mssql-python maintainers:
52+
- Create an ADO Work Item following internal processes
53+
- Link the ADO Work Item in the "ADO Work Item" section above
54+
- Follow the PR title format and provide a meaningful summary
3255
-->

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

Lines changed: 30 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -17,49 +17,62 @@ jobs:
1717
script: |
1818
const title = context.payload.pull_request.title;
1919
const body = context.payload.pull_request.body;
20+
const prAuthor = context.payload.pull_request.user.login;
2021
22+
// Validate title prefix for all contributors
2123
const validTitlePrefixes = [
22-
'FEAT:', 'CHORE:', 'FIX:', 'DOC:', 'STYLE:', 'REFACTOR:', 'RELEASE:'
24+
'FEAT:', 'CHORE:', 'FIX:', 'DOC:', 'STYLE:', 'REFACTOR:',
25+
'RELEASE:'
2326
];
2427
25-
const hasValidPrefix = validTitlePrefixes.some(prefix => title.startsWith(prefix));
28+
const hasValidPrefix = validTitlePrefixes.some(prefix =>
29+
title.startsWith(prefix));
2630
2731
if (!hasValidPrefix) {
2832
core.setFailed(`❌ PR title must start with one of the allowed prefixes:\n${validTitlePrefixes.join(', ')}`);
2933
}
3034
31-
const azureWorkItemLinkPattern = /https:\/\/sqlclientdrivers\.visualstudio\.com\/[^\/]+\/_workitems\/edit\/\d+/i;
35+
// Validate that either GitHub issue link or ADO Work Item link is present
36+
const azureWorkItemLinkPattern =
37+
/https:\/\/sqlclientdrivers\.visualstudio\.com\/[^\/]+\/_workitems\/edit\/\d+/i;
38+
const githubIssueLinkPattern =
39+
/(https:\/\/github\.com\/microsoft\/mssql-python\/issues\/\d+|#\d+)/i;
40+
3241
const hasWorkItemLink = azureWorkItemLinkPattern.test(body);
42+
const hasGitHubIssueLink = githubIssueLinkPattern.test(body);
3343
34-
if (!hasWorkItemLink) {
35-
core.setFailed(`❌ PR should contain a valid ADO Work Item ID.\nExpected a hyperlink in the format: https://sqlclientdrivers.visualstudio.com/.../_workitems/edit/<ID>\nPlease ensure the ADO task hyperlink is present in the PR description.`);
44+
if (!hasWorkItemLink && !hasGitHubIssueLink) {
45+
core.setFailed(`❌ PR must contain either a valid GitHub issue link OR a valid ADO Work Item link.\nGitHub issue format: https://github.com/microsoft/mssql-python/issues/XXX or #XXX\nADO Work Item format: https://sqlclientdrivers.visualstudio.com/.../_workitems/edit/<ID>\nPlease include at least one reference in the PR description.\nFor more information, see CONTRIBUTING.md.`);
3646
}
37-
38-
// Check if PR description contains a meaningful summary section with actual content
39-
const summaryPattern = /###\s*Summary\s*\r?\n([\s\S]*?)(\r?\n###|$)/;
47+
48+
// Check if PR description contains a meaningful summary section
49+
// with actual content (for all contributors)
50+
const summaryPattern =
51+
/###\s*Summary\s*\r?\n([\s\S]*?)(\r?\n###|$)/;
4052
const summaryMatch = body.match(summaryPattern);
41-
53+
4254
let hasValidSummary = false;
43-
55+
4456
if (summaryMatch && summaryMatch[1]) {
4557
// Extract the summary content
4658
const summaryContent = summaryMatch[1];
47-
59+
4860
// Remove all HTML comments including the template placeholder
49-
const contentWithoutComments = summaryContent.replace(/<!--[\s\S]*?-->/g, '');
50-
61+
const contentWithoutComments =
62+
summaryContent.replace(/<!--[\s\S]*?-->/g, '');
63+
5164
// Remove whitespace and check if there's actual text content
5265
const trimmedContent = contentWithoutComments.trim();
53-
66+
5467
// Check if there's at least 10 characters of meaningful content
5568
hasValidSummary = trimmedContent.length >= 10;
5669
}
57-
70+
5871
if (!hasValidSummary) {
59-
core.setFailed(`❌ PR must contain a meaningful summary section with actual text content (minimum 10 characters).
60-
Please add a clear description under the '### Summary' heading in your PR description.`);
72+
core.setFailed(`❌ PR must contain a meaningful summary section with actual text content (minimum 10 characters).\nPlease add a clear description under the '### Summary' heading in your PR description.`);
6173
}
6274
- name: Add size label based on PR diff
75+
if: github.event.pull_request.head.repo.full_name == github.repository
6376
uses: actions/github-script@v7
6477
with:
6578
script: |

CONTRIBUTING.md

Lines changed: 29 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,4 +11,32 @@ instructions provided by the bot. You will only need to do this once across all
1111

1212
This project has adopted the [Microsoft Open Source Code of Conduct](https://opensource.microsoft.com/codeofconduct/).
1313
For more information see the [Code of Conduct FAQ](https://opensource.microsoft.com/codeofconduct/faq/)
14-
or contact [opencode@microsoft.com](mailto:opencode@microsoft.com) with any additional questions or comments.
14+
or contact [opencode@microsoft.com](mailto:opencode@microsoft.com) with any additional questions or comments.
15+
16+
## Before Contributing
17+
18+
### For External Contributors
19+
20+
If you are an external contributor (not a Microsoft organization member), please follow these steps:
21+
22+
1. **Create a GitHub Issue First**: Before submitting a pull request, create a GitHub issue describing the bug, feature request, or improvement you want to contribute.
23+
2. **Link the Issue in Your PR**: When you submit your pull request, please use the PR template and include a link to the GitHub issue in the PR description using the format: `https://github.com/microsoft/mssql-python/issues/XXX`
24+
3. **Follow PR Guidelines**: Ensure your PR title follows the required prefix format (FEAT:, FIX:, DOC:, etc.) and includes a meaningful summary.
25+
26+
### For Microsoft Organization Members
27+
28+
If you are a Microsoft organization member (internal contributor):
29+
30+
1. **Create an ADO Work Item**: Follow your internal process to create an Azure DevOps (ADO) work item.
31+
2. **Link the ADO Work Item**: Include the ADO work item link in your PR description using the format: `https://sqlclientdrivers.visualstudio.com/.../workitems/edit/ID`
32+
3. **Follow PR Guidelines**: Ensure your PR title follows the required prefix format and includes a meaningful summary.
33+
34+
## Pull Request Requirements
35+
36+
All pull requests must include:
37+
38+
- **Valid Title Prefix**: Your PR title must start with one of: `FEAT:`, `CHORE:`, `FIX:`, `DOC:`, `STYLE:`, `REFACTOR:`, or `RELEASE:`
39+
- **Meaningful Summary**: Include a clear description of your changes under the "### Summary" section in the PR description (minimum 10 characters)
40+
- **Issue/Work Item Link** (only one required):
41+
- External contributors: Link to a GitHub issue
42+
- Microsoft org members: Link to an ADO work item

PyPI_Description.md

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9,9 +9,10 @@ We are making progress - The Public Preview of our driver is now available! This
99
### What's Included:
1010

1111
- Everything from previous releases
12-
- **Linux Support**: The mssql-python driver now supports Linux OS (manylinux2014) - Ubuntu, Debian and RHEL, enabling seamless development on Linux based systems. Added Linux driver libraries and related logic for architecture-specific handling and ODBC driver path resolution. Support for other Linux based distros will come in subsequent releases.
13-
- **Connection Pooling Support for MacOS and Linux**: Implemented connection pooling features for MacOS and Linux, including tests and unified code support for pooling across platforms.
14-
Expanded Pipeline/Test Matrix: Added/expanded support for Python versions < 3.13 and enhanced database setup for testing, including LocalDB and Docker-based SQL Server.
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.
1516

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

README.md

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -48,17 +48,24 @@ By adhering to the DB API 2.0 specification, the mssql-python module ensures com
4848

4949
### Support for Microsoft Entra ID Authentication
5050

51-
The Microsoft mssql-python driver enables Python applications to connect to Microsoft SQL Server, Azure SQL Database, or Azure SQL Managed Instance using Microsoft Entra ID identities. It supports various authentication methods, including username and password, Microsoft Entra managed identity, and Integrated Windows Authentication in a federated, domain-joined environment. Additionally, the driver supports Microsoft Entra interactive authentication and Microsoft Entra managed identity authentication for both system-assigned and user-assigned managed identities.
51+
The Microsoft mssql-python driver enables Python applications to connect to Microsoft SQL Server, Azure SQL Database, or Azure SQL Managed Instance using Microsoft Entra ID identities. It supports a variety of authentication methods, including username and password, Microsoft Entra managed identity (system-assigned and user-assigned), Integrated Windows Authentication in a federated, domain-joined environment, interactive authentication via browser, device code flow for environments without browser access, and the default authentication method based on environment and configuration. This flexibility allows developers to choose the most suitable authentication approach for their deployment scenario.
5252

5353
EntraID authentication is now fully supported on MacOS and Linux but with certain limitations as mentioned in the table:
5454

5555
| Authentication Method | Windows Support | macOS/Linux Support | Notes |
5656
|----------------------|----------------|---------------------|-------|
5757
| ActiveDirectoryPassword | ✅ Yes | ✅ Yes | Username/password-based authentication |
58-
| ActiveDirectoryInteractive | ✅ Yes | ❌ No | Only works on Windows |
58+
| ActiveDirectoryInteractive | ✅ Yes | ✅ Yes | Interactive login via browser; requires user interaction |
5959
| ActiveDirectoryMSI (Managed Identity) | ✅ Yes | ✅ Yes | For Azure VMs/containers with managed identity |
6060
| ActiveDirectoryServicePrincipal | ✅ Yes | ✅ Yes | Use client ID and secret or certificate |
6161
| ActiveDirectoryIntegrated | ✅ Yes | ❌ No | Only works on Windows (requires Kerberos/SSPI) |
62+
| ActiveDirectoryDeviceCode | ✅ Yes | ✅ Yes | Device code flow for authentication; suitable for environments without browser access |
63+
| ActiveDirectoryDefault | ✅ Yes | ✅ Yes | Uses default authentication method based on environment and configuration |
64+
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.
6269

6370
### Enhanced Pythonic Features
6471

benchmarks/README.md

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
# Benchmarks
2+
3+
This directory contains benchmark scripts for testing the performance of various database operations using `pyodbc` and `mssql_python`. The goal is to evaluate and compare the performance of these libraries for common database operations.
4+
5+
## Why Benchmarks?
6+
- To measure the efficiency of `pyodbc` and `mssql_python` in handling database operations.
7+
- To identify performance bottlenecks and optimize database interactions.
8+
- To ensure the reliability and scalability of the libraries under different workloads.
9+
10+
## How to Run Benchmarks
11+
1. **Set Up the Environment Variable**:
12+
- Ensure you have a running SQL Server instance.
13+
- Set the `DB_CONNECTION_STRING` environment variable with the connection string to your database. For example:
14+
```cmd
15+
set DB_CONNECTION_STRING=Server=your_server;Database=your_database;UID=your_user;PWD=your_password;
16+
```
17+
18+
2. **Install Richbench - Benchmarking Tool**:
19+
- Install richbench :
20+
```cmd
21+
pip install richbench
22+
```
23+
24+
3. **Run the Benchmarks**:
25+
- Execute richbench from the parent folder (mssql-python) :
26+
```cmd
27+
richbench benchmarks
28+
```
29+
Results will be displayed in the terminal with detailed performance metrics.
30+
31+
## Key Features of `bench_mssql.py`
32+
- **Comprehensive Benchmarks**: Includes SELECT, INSERT, UPDATE, DELETE, complex queries, stored procedures, and transaction handling.
33+
- **Error Handling**: Each benchmark function is wrapped with error handling to ensure smooth execution.
34+
- **Progress Messages**: Clear progress messages are printed during execution for better visibility.
35+
- **Automated Setup and Cleanup**: The script automatically sets up and cleans up the database environment before and after the benchmarks.
36+
37+
## Notes
38+
- Ensure the database user has the necessary permissions to create and drop tables and stored procedures.
39+
- The script uses permanent tables prefixed with `perfbenchmark_` for benchmarking purposes.
40+
- A stored procedure named `perfbenchmark_stored_procedure` is created and used during the benchmarks.

0 commit comments

Comments
 (0)