Commit dca1076
committed
Merged PR 5237: Feat: Add fetchMany and FetchAll API to DDBC bindings to get data in batch and complete data from current ResultSet
Feat: Add functions to fetch data one by one and in batches from DDBC bindings
----
#### AI description (iteration 1)
#### PR Classification
New feature
#### PR Summary
This pull request adds functions to fetch data one by one and in batches from DDBC bindings.
- `mssql_python/pybind/ddbc_bindings.cpp`: Added `FetchMany_wrap` and `FetchOne_wrap` functions for fetching multiple and single rows of data, respectively.
- `mssql_python/testing_ddbc_bindings.py`: Introduced `fetch_data_onebyone` and `fetch_data_many` functions for testing the new fetch capabilities.
- Updated debug print statements to use `std::cout` for consistency.
This pull request introduces several enhancements and fixes to the FetchMany_wrap function in the ddbc_bindings.cpp file. The changes ensure proper handling and binding of various SQL data types, including character, wide character, integer, floating-point, timestamp, and binary types. Additionally, the PR includes a SQL Server query to create a table with all these types and insert sample data for testing.
Changes Made
Data Type Handling and Binding:
Added proper handling and binding for the following SQL data types:
SQL_CHAR
SQL_VARCHAR
SQL_LONGVARCHAR
SQL_WCHAR
SQL_WVARCHAR
SQL_WLONGVARCHAR
SQL_INTEGER
SQL_SMALLINT
SQL_REAL
SQL_FLOAT
SQL_DECIMAL
SQL_DOUBLE
SQL_TIMESTAMP
SQL_DATETIME
SQL_BIGINT
SQL_TYPE_DATE
SQL_TIME
SQL_GUID
SQL_BINARY
SQL_VARBINARY
SQL_LONGVARBINARY
Buffer Resizing and Binding:
Resized buffers appropriately based on the fetch size and column size.
Used SQLBindCol_ptr to bind columns to the respective buffers.
Data Fetching and Conversion:
Implemented data fetching and conversion logic for each data type.
Ensured proper null-termination for wide character data.
Added debug statements to verify data fetching and conversion.
SQL Server Table Creation and Data Insertion:
Provided a SQL Server query to create a table (TestTable) with columns of various data types.
Inserted 5 rows of sample data into the table for testing purposes.
Detailed Code Changes
ddbc_bindings.cpp:
Updated the FetchMany_wrap function to handle and bind various SQL data types.
Added buffer resizing and binding logic for each data type.
Implemented data fetching and conversion logic, including proper null-termination for wide character data.
Added debug statements to verify data fetching and conversion.
SQL Server Query:
Created a table named TestTable with columns of various data types.
Inserted 5 rows of sample data into the table.
Testing
Verified the proper handling and binding of various SQL data types.
Ensured that data is correctly fetched and converted for each data type.
Tested the SQL Server query to create the table and insert sample data.
Additional Notes
The changes ensure that the FetchMany_wrap function can handle a wide range of SQL data types, improving the robustness and versatility of the code.
The provided SQL Server query can be used to create a test table and insert sample data for further testing and v...1 parent b13de8f commit dca1076
2 files changed
Lines changed: 540 additions & 93 deletions
0 commit comments