-
Notifications
You must be signed in to change notification settings - Fork 28
FEAT: C++ support for pooling #64
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
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
Refactors database connection and cursor management by replacing low-level ODBC handle code with a high-level ddbc_bindings.Connection, introduces a connection pool, and streamlines transaction logic.
- Switches to
ddbc_bindings.ConnectionandConnectionPoolManagerto manage connections and pooling. - Removes legacy ODBC wrapper functions and simplifies cursor and transaction methods.
- Updates build configuration and tests to align with the new abstraction.
Reviewed Changes
Copilot reviewed 10 out of 10 changed files in this pull request and generated 3 comments.
Show a summary per file
| File | Description |
|---|---|
| tests/test_005_exceptions.py | Adjust expected exception type and message |
| mssql_python/pybind/ddbc_bindings.h/.cpp | Added pybind11 includes, cleaned up wrappers, and implemented SqlHandle destructor |
| mssql_python/pybind/connection/connection_pool.h/.cpp | Added ConnectionPool and ConnectionPoolManager |
| mssql_python/pybind/connection/connection.h/.cpp | Updated Connection and ConnectionHandle to support pooling and attribute logic |
| mssql_python/pybind/CMakeLists.txt | Included connection_pool.cpp in the build |
| mssql_python/cursor.py | Simplified statement handle allocation and removal of closed-check |
| mssql_python/connection.py | Replaced manual handle management with ddbc_bindings.Connection |
Comments suppressed due to low confidence (2)
tests/test_005_exceptions.py:128
- [nitpick] Matching the full error message is brittle. Consider asserting substring or using a regex to validate key parts (e.g.
"keyword supplied").
with pytest.raises(RuntimeError) as excinfo:
mssql_python/cursor.py:425
_reset_cursorfreeshstmtbut does not reallocate a new statement handle. Consider callingself._initialize_cursor()afterfree()to restorehstmt.
self.hstmt.free()
c122382 to
7262d8b
Compare
37011f0 to
d742791
Compare
d742791 to
079bf57
Compare
14ae7f5 to
2cc10bf
Compare
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 a few comments. Some of them can be put into backlog for future improvements. A couple of them can be thought to get fixed right away.
5b10446 to
f576b08
Compare
This pull request introduces connection pooling to improve database connection management in the
mssql_pythonproject. Key changes include the addition of aConnectionPoolclass, updates to theConnectionclass to support pooling, and modifications to the Python bindings to expose pooling functionality.Connection Pooling Implementation:
ConnectionPoolandConnectionPoolManagerclasses: AddedConnectionPoolfor managing reusable database connections andConnectionPoolManageras a singleton to manage multiple pools. These classes handle connection acquisition, release, and idle timeout logic. (mssql_python/pybind/connection/connection_pool.cpp- [1]mssql_python/pybind/connection/connection_pool.h- [2]Updates to
ConnectionClass:Connectionclass to include attributes and methods for pooling, such as_lastUsed,isAlive(), andreset(). AddedConnectionHandleas a wrapper for pooled connections. (mssql_python/pybind/connection/connection.cpp- [1] [2] [3] [4] [5]mssql_python/pybind/connection/connection.h- [6] [7]Python Bindings:
Connectionclass withConnectionHandleand added a globalenable_poolingfunction for configuring pooling parameters. (mssql_python/pybind/ddbc_bindings.cpp- [1] [2]Build System:
CMakeLists.txtto include the newconnection_pool.cppfile in the build process. (mssql_python/pybind/CMakeLists.txt- mssql_python/pybind/CMakeLists.txtL93-R93)Header File Updates:
connection_pool.hto relevant files for access to pooling functionality. (mssql_python/pybind/connection/connection.cpp- [1]mssql_python/pybind/ddbc_bindings.cpp- [2]Checklist