-
Notifications
You must be signed in to change notification settings - Fork 28
FEAT: Integrate python <->C++ flow with C++ connection class #55
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
FEAT: Integrate python <->C++ flow with C++ connection class #55
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
Adds a new C++ backend for ODBC handle management and switches the Python modules to use it instead of manual handle calls. Major changes include:
- Introducing
ddbc_bindings.hand associated C++ classes (DriverLoader,SqlHandle,Connection) to centralize and RAII-manage ODBC API calls. - Updating Python’s
connection.pyandcursor.pyto delegate operations to the new C++ConnectionandSqlHandlebindings. - Removing legacy Python initialization, handle allocation/free logic, and replacing it with calls into the C++ layer.
Reviewed Changes
Copilot reviewed 6 out of 6 changed files in this pull request and generated 3 comments.
Show a summary per file
| File | Description |
|---|---|
| mssql_python/pybind/ddbc_bindings.h | Added ODBC typedefs, function pointers, DriverLoader, SqlHandle |
| mssql_python/pybind/connection/connection.h | Defined C++ Connection class and methods |
| mssql_python/pybind/connection/connection.cpp | Implemented C++ Connection member functions |
| mssql_python/cursor.py | Removed manual handle allocation/free; uses C++ bindings |
| mssql_python/connection.py | Replaced Python handle management with C++ Connection |
Comments suppressed due to low confidence (4)
mssql_python/pybind/ddbc_bindings.h:4
- Typo in comment: 'is file' should be 'this file'.
// INFO|TODO - Note that is file is Windows specific right now. Making it arch agnostic will be
mssql_python/pybind/connection/connection.h:28
- [nitpick] The member
_connis unused within the C++Connectionclass and creates a circular reference; consider removing it.
std::shared_ptr<Connection> _conn;
mssql_python/connection.py:168
self._conn.commit()calls a method that isn't defined in the C++Connectionclass. Implement acommit()wrapper (callingend_transaction(SQL_COMMIT)) or update Python to useend_transactiondirectly.
self._conn.commit()
mssql_python/connection.py:184
self._conn.rollback()references a non-existent C++ method. Provide arollback()wrapper (callingend_transaction(SQL_ROLLBACK)) or adjust Python to use theend_transactionAPI.
self._conn.rollback()
119f8ce to
9813c41
Compare
56cf353 to
c89cfbe
Compare
9813c41 to
657b68b
Compare
f979de7 to
896f34d
Compare
3c7124b to
87257e7
Compare
87257e7 to
b22b197
Compare
5ecc8fd to
6a077c6
Compare
62f23ed to
3240394
Compare
6a077c6 to
c8dfd0e
Compare
fa7a9fa to
a9ee888
Compare
This pull request makes the database connection and cursor handling in the
mssql_pythonmodule via new C++Connectionclass and simplifying the Python-side implementation. The changes include replacing low-level connection management with a higher-level abstraction, removing redundant methods, and delegating key operations to the new C++ backend. Below are the most important changes grouped by theme:Refactoring Python Connection Management
henv,hdbc) and initialization inmssql_python/connection.pywith a newConnectionclass from the C++ backend. The_initializer,_allocate_environment_handle,_allocate_connection_handle, and related methods were removed.commit,rollback) and connection lifecycle methods (close) by delegating their logic to the C++Connectionclass.set_autocommitandget_autocommitmethods from the C++Connectionclass.Refactoring Python Cursor Management
mssql_python/cursor.pyand delegated statement handle allocation to the C++Connectionclass.Integration with Python Bindings
ddbc_bindings.cppto include the newConnectionclass, enabling its use in the Python layer.Checklist