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: varbinarymax streaming support in execute() (#231)
### Work Item / Issue Reference
<!--
IMPORTANT: Please follow the PR template guidelines below.
For mssql-python maintainers: Insert your ADO Work Item ID below (e.g.
AB#37452)
For external contributors: Insert Github Issue number below (e.g. #149)
Only one reference is required - either GitHub issue OR ADO Work Item.
-->
<!-- mssql-python maintainers: ADO Work Item -->
>
[AB#33395](https://sqlclientdrivers.visualstudio.com/c6d89619-62de-46a0-8b46-70b92a84d85e/_workitems/edit/33395)
<!-- External contributors: GitHub Issue -->
> GitHub Issue: #<ISSUE_NUMBER>
-------------------------------------------------------------------
### Summary
<!-- Insert your summary of changes below. Minimum 10 characters
required. -->
This pull request adds support for streaming large binary parameters
(bytes and bytearray) to SQL Server using VARBINARY(MAX), removing the
previous limitation that prevented inserting binary data larger than
8192 bytes. The changes update both the Python and C++ layers to detect
large binary parameters, use deferred execution (DAE) for streaming, and
add new tests to verify correct handling of both small and large binary
data.
**Binary parameter streaming support:**
* Updated `_map_sql_type` in `cursor.py` to detect large
`bytes`/`bytearray` parameters (>8000 bytes) and mark them for
VARBINARY(MAX) streaming, while still handling small binaries directly.
* Modified parameter binding in `ddbc_bindings.cpp` to use deferred
execution for large binaries, and to allocate/bind buffers correctly for
both small and large binary parameters.
* Enhanced `SQLExecute_wrap` in `ddbc_bindings.cpp` to stream large
binary data using `SQLPutData` in chunks during execution.
**Testing improvements:**
* Refactored and expanded tests in `test_004_cursor.py` to separately
verify small/medium binary inserts and to add a new test for inserting
large binary data (>8000 bytes) using streaming.
[[1]](diffhunk://#diff-82594712308ff34afa8b067af67db231e9a1372ef474da3db121e14e4d418f69L6278-R6296)
[[2]](diffhunk://#diff-82594712308ff34afa8b067af67db231e9a1372ef474da3db121e14e4d418f69L6320-R6342)
<!--
### 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