-
Notifications
You must be signed in to change notification settings - Fork 8
FEAT: Bulk Copy #73
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
FEAT: Bulk Copy #73
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull Request Overview
This PR introduces new Bulk Copy functionality in the mssql_python library by implementing a new BCPClient class and enhancing BCPOptions and ColumnFormat to support flexible bulk copy operations. Key changes include:
- Addition of the BCPClient class and associated pybind11 bindings in C++ for managing BCP operations.
- Updates to BCPOptions and ColumnFormat with extra validations and support for new configuration parameters.
- New integration scripts and sample data/format files to facilitate testing of bulk copy operations.
Reviewed Changes
Copilot reviewed 16 out of 16 changed files in this pull request and generated 1 comment.
Show a summary per file
File | Description |
---|---|
tests/test_007_bcpOptions.py | Unit tests to validate the new BCPOptions and ColumnFormat behavior. |
mssql_python/pybind/ddbc_bindings.{h,cpp} | Updated function pointer loading and inclusion of new BCP API pointers. |
mssql_python/pybind/connection/connection.cpp | BCP-specific connection attribute handling added. |
mssql_python/pybind/bcp/{bcp_wrapper.h,cpp} | New BCPWrapper implementation with methods for initializing and executing BCP. |
mssql_python/CMakeLists.txt | Updated to include BCPWrapper sources and header directories. |
mssql_python/constants.py | Added new enum for BCP control options. |
mssql_python/bcp_options.py | Enhanced validation and options for bulk copy configurations. |
mssql_python/bcp_main.py | New BCPClient class implementation that wraps BCPWrapper operations. |
main_bcp.py | Standalone example script demonstrating the BCP functionality. |
Data and format files | Added sample BCP data (.bcp), Unicode data file, and format files (.fmt). |
Comments suppressed due to low confidence (1)
mssql_python/pybind/bcp/bcp_wrapper.cpp:197
- The two overloads of bcp_control show inconsistent error handling—one throws an exception when in an invalid state while the other returns SQL_ERROR. Consider adopting a consistent error handling strategy across both overloads.
if (!_bcp_initialized || _bcp_finished) {
#include <stdexcept> | ||
#include <unordered_map> | ||
#include <string> // For std::to_string, std::string | ||
#include <iostream> // Added for std::cout |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
[nitpick] Consider replacing raw std::cout debug prints with a dedicated logging framework to ensure consistent logging behavior in production code.
Copilot uses AI. Check for mistakes.
… jahnvi/bcp_py_apis
… jahnvi/bcp_py_apis
This pull request introduces significant enhancements to the Bulk Copy Program (BCP) functionality in the
mssql_python
library, including the addition of new classes, methods, and configuration options to support bulk data operations. It also includes updates to data files and format files to facilitate testing and integration.Enhancements to BCP functionality:
New
BCPClient
class for bulk copy operations:BCPClient
inmssql_python/bcp_main.py
to manage bulk copy operations using the BCP utility. This includes initialization, validation, and execution of BCP operations with detailed logging.Updates to
BCPOptions
andColumnFormat
classes:ColumnFormat
with new attributes such asuser_data_type
andcol_name
, along with default values forprefix_len
anddata_len
.in
,out
,format
,query
) and file modes (native
,char
,unicode
) inBCPOptions
.Integration and usage:
New
main_bcp.py
script:Initialization of BCP components:
mssql_python/__init__.py
to include imports forBCPClient
,BCPOptions
, andColumnFormat
.Data and format file updates:
Employee data file (
EmployeeFullNames.bcp
):Format files:
EmployeeFullNames.fmt
andTestBCP.fmt
to define data structure and encoding for bulk operations. [1] [2]Unicode data file (
data_unicode.csv
):