FEAT: Make _bulkcopy a public API by saurabh500 · Pull Request #449 · microsoft/mssql-python
Pull request overview
This PR promotes the cursor bulk copy helper from a private method (_bulkcopy) to a public API (bulkcopy), aligning the test suite with the new method name and adjusting the runtime error messaging when the native mssql_py_core dependency is unavailable.
Changes:
- Renamed
Cursor._bulkcopy(...)toCursor.bulkcopy(...)to expose bulk copy as a public API. - Updated the bulkcopy integration test to call
cursor.bulkcopy(...). - Updated the ImportError message shown when
mssql_py_corecannot be imported.
Reviewed changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated 1 comment.
| File | Description |
|---|---|
| tests/test_019_bulkcopy.py | Updates test to use the new public cursor.bulkcopy() API. |
| mssql_python/cursor.py | Renames the method to bulkcopy() and changes the ImportError message for missing/unloadable mssql_py_core. |
Comments suppressed due to low confidence (1)
mssql_python/cursor.py:2515
bulkcopyis now part of the public Cursor API, but it’s still excluded from coverage via# pragma: no cover. Since there’s an integration test module for bulkcopy, consider removing the pragma (or narrowing the exclusion to only the truly untestable branches) so coverage will catch regressions in this public method.
def bulkcopy(
self,
table_name: str,
data: Iterable[Union[Tuple, List]],
batch_size: int = 0,
timeout: int = 30,
column_mappings: Optional[Union[List[str], List[Tuple[int, str]]]] = None,
keep_identity: bool = False,
check_constraints: bool = False,
table_lock: bool = False,
keep_nulls: bool = False,
fire_triggers: bool = False,
use_internal_transaction: bool = False,
): # pragma: no cover
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.