FEAT: Adding statistics API in cursor class #198
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Work Item / Issue Reference
Summary
This pull request adds support for retrieving table and index statistics via the ODBC
SQLStatistics
API in themssql_python
package. The main changes include implementing thestatistics
method on the Python cursor, exposing the required C++ bindings, defining new constants, and introducing comprehensive tests to ensure the new functionality works as expected.New statistics feature:
statistics
method to theCursor
class inmssql_python/cursor.py
, allowing users to retrieve index and table statistics for a given table, with options to filter by uniqueness, catalog, schema, and quickness of statistics retrieval.SQL_INDEX_UNIQUE
,SQL_INDEX_ALL
,SQL_QUICK
,SQL_ENSURE
) inmssql_python/constants.py
to support the statistics method options.C++ binding and integration:
SQLStatisticsFunc
type and related function pointer tomssql_python/pybind/ddbc_bindings.h
and initialized it inmssql_python/pybind/ddbc_bindings.cpp
.SQLStatistics_wrap
function and exposed it to Python via theDDBCSQLStatistics
binding in the pybind module.Testing:
tests/test_004_cursor.py
for the newstatistics
method, including tests for setup, basic functionality, unique index filtering, empty tables, non-existent tables, result structure, catalog filtering, thequick
parameter, and cleanup.