-
Notifications
You must be signed in to change notification settings - Fork 28
FEAT: Python support for Pooling #62
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
Conversation
2be7638 to
c74ad07
Compare
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 refactors the mssql_python driver to use a unified C++ ddbc_bindings.Connection class for all connection operations, removes legacy handle‐management code, and adds a placeholder API for connection pooling.
- Swap out manual ODBC handle setup/teardown for
ddbc_bindings.Connection - Introduce
pool_config.enable_poolingand pass pooling flag into new C++Connection - Update cursor to call into
Connection.alloc_statement_handleand clean up redundant logic
Reviewed Changes
Copilot reviewed 9 out of 9 changed files in this pull request and generated 4 comments.
Show a summary per file
| File | Description |
|---|---|
| tests/test_005_exceptions.py | Updated expected exception type/message for invalid connection |
| mssql_python/pybind/ddbc_bindings.h | Added includes, mutex, ErrorInfo struct, and once_flag |
| mssql_python/pybind/ddbc_bindings.cpp | Removed old wrap functions, adjusted SqlHandle destructor, bound new Connection API |
| mssql_python/pybind/connection/connection.h | Introduced new C++ Connection class signature and members |
| mssql_python/pybind/connection/connection.cpp | Fully implemented Connection logic, error handling, and pooling flag |
| mssql_python/pool_config.py | New module with enable_pooling stub |
| mssql_python/cursor.py | Use Connection.alloc_statement_handle() and tidy free logic |
| mssql_python/connection.py | Swap to using C++ Connection, remove legacy handle methods |
| mssql_python/init.py | Exported enable_pooling |
Comments suppressed due to low confidence (1)
mssql_python/pybind/ddbc_bindings.h:15
- [nitpick]
m_driverLoadedis never initialized or used after switching tostd::call_once. Remove it or initialize/use it consistently to avoid confusion.
bool m_driverLoaded;
sumitmsft
left a comment
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.
I have added a few comments to keep a note of. Please see if you can incorporate them when you make changes to ddbc_bindings.cpp.
d1f8009 to
856915a
Compare
856915a to
daa63ed
Compare
bewithgaurav
left a comment
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.
Approved with some minor suggestions for refactoring, can be added as a TODO for later use.
This pull request introduces connection pooling functionality to the
mssql_pythonlibrary. The changes include adding a new module to manage pooling configuration, modifying existing connection logic to support pooling, and extending the C++ bindings to handle the new pooling parameter.Connection pooling feature:
mssql_python/pool_config.py: Added a new module to manage connection pooling, including a global_pooling_enabledflag and anenable_poolingfunction to configure pooling parameters.Integration of pooling into Python connection logic:
mssql_python/connection.py: Updated theConnectionclass to include the_pooling_enabledflag when creating a connection, ensuring pooling is respected in subsequent operations.mssql_python/__init__.py: Imported theenable_poolingfunction from the newpool_configmodule to make it accessible at the package level.Extension of C++ bindings for pooling:
mssql_python/pybind/connection/connection.cppandconnection.h: Modified theConnectionconstructor to accept a newuse_poolingparameter and store it as_usePool. [1] [2]mssql_python/pybind/ddbc_bindings.cpp: Updated the Pybind11 bindings for theConnectionclass to include theuse_poolingparameter, allowing Python code to pass pooling configuration to the underlying C++ implementation.Checklist