You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
FEAT: Pass all connection string params to mssql-py-core for bulk copy (#439)
### Work Item / Issue Reference
<!--
IMPORTANT: Please follow the PR template guidelines below.
For mssql-python maintainers: Insert your ADO Work Item ID below
For external contributors: Insert Github Issue number below
Only one reference is required - either GitHub issue OR ADO Work Item.
-->
<!-- mssql-python maintainers: ADO Work Item -->
>
[AB#42663](https://sqlclientdrivers.visualstudio.com/c6d89619-62de-46a0-8b46-70b92a84d85e/_workitems/edit/42663)
<!-- External contributors: GitHub Issue -->
> GitHub Issue: #<ISSUE_NUMBER>
-------------------------------------------------------------------
### Summary
<!-- Insert your summary of changes below. Minimum 10 characters
required. -->
This pull request refactors and simplifies how ODBC connection string
parameters are translated for use with the bulk copy feature in
`mssql_python`. The key change is the introduction of a new helper
function, `connstr_to_pycore_params`, which centralizes and standardizes
the parameter mapping logic. This reduces code duplication, improves
maintainability, and ensures sensitive data is handled more securely.
**Bulk copy connection context refactor:**
* Added a new helper function `connstr_to_pycore_params` in
`mssql_python/helpers.py` to translate ODBC connection string parameters
into the format expected by the py-core bulk copy path, including type
conversion and key normalization.
* Updated `mssql_python/cursor.py` to use `connstr_to_pycore_params` for
building the `pycore_context` dictionary, replacing the previous inline
mapping and logic.
[[1]](diffhunk://#diff-deceea46ae01082ce8400e14fa02f4b7585afb7b5ed9885338b66494f5f38280L20-R20)
[[2]](diffhunk://#diff-deceea46ae01082ce8400e14fa02f4b7585afb7b5ed9885338b66494f5f38280L2588-R2592)
**Security and code quality improvements:**
* Simplified sensitive data cleanup in the bulk copy context by
iterating over a tuple of sensitive keys instead of repeating `pop`
calls.
* Removed redundant manual extraction and assignment of authentication
parameters in favor of the new helper function, reducing the risk of
accidentally logging or exposing credentials.
**Documentation and maintainability:**
* Added detailed documentation to the new helper function explaining its
purpose, supported keys, and conversion logic.
* Added a clarifying comment in `cursor.py` indicating the mapping from
ODBC connection-string keywords.
<!--
### PR Title Guide
> For feature requests
FEAT: (short-description)
> For non-feature requests like test case updates, config updates ,
dependency updates etc
CHORE: (short-description)
> For Fix requests
FIX: (short-description)
> For doc update requests
DOC: (short-description)
> For Formatting, indentation, or styling update
STYLE: (short-description)
> For Refactor, without any feature changes
REFACTOR: (short-description)
> For release related changes, without any feature changes
RELEASE: #<RELEASE_VERSION> (short-description)
### Contribution Guidelines
External contributors:
- Create a GitHub issue first:
https://github.com/microsoft/mssql-python/issues/new
- Link the GitHub issue in the "GitHub Issue" section above
- Follow the PR title format and provide a meaningful summary
mssql-python maintainers:
- Create an ADO Work Item following internal processes
- Link the ADO Work Item in the "ADO Work Item" section above
- Follow the PR title format and provide a meaningful summary
-->
0 commit comments