-
Notifications
You must be signed in to change notification settings - Fork 31
FEAT: adding connection class structure in C++ #52
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
This PR provides a foundational implementation for a C++ MSSQL connection layer by introducing a new Connection class together with related utility functions and function pointer typedefs for ODBC API interactions.
- Added ddbc_bindings.h with various function pointer typedefs and external declarations for ODBC APIs.
- Introduced Connection class header and a minimal implementation in connection.cpp with placeholder methods for connection management.
Reviewed Changes
Copilot reviewed 4 out of 4 changed files in this pull request and generated 1 comment.
| File | Description |
|---|---|
| mssql_python/pybind/ddbc_bindings.h | Introduces ODBC API function pointer typedefs and helper functions. |
| mssql_python/pybind/connection/connection.h | Defines the Connection class interface for managing MSSQL connections. |
| mssql_python/pybind/connection/connection.cpp | Provides placeholder implementations for Connection methods. |
Comments suppressed due to low confidence (1)
mssql_python/pybind/connection/connection.h:29
- [nitpick] The member variable '_conn' in the Connection class is ambiguous, as its purpose is unclear given the context. Consider reviewing its necessity or renaming it to better reflect its intended use.
std::shared_ptr<Connection> _conn;
6313410 to
be11908
Compare
7727ace to
eb7161e
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 adds a new C++ Connection class to manage MSSQL database connectivity in the mssql_python module, including stubs for connection, transaction, and autocommit operations.
- Introduces
Connectionclass definition inconnection.hwith handles, connection string, and autocommit state. - Adds method stubs and lifecycle logging in
connection.cpp. - Sets up the basic structure for future implementation of ODBC operations.
Reviewed Changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated 3 comments.
| File | Description |
|---|---|
| mssql_python/pybind/connection/connection.h | Defines Connection class, members, and method signatures |
| mssql_python/pybind/connection/connection.cpp | Implements constructor, destructor, and stubs for methods with logging |
Comments suppressed due to low confidence (2)
mssql_python/pybind/connection/connection.h:7
- [nitpick] Use a more specific include guard macro (e.g. MSSQL_PYTHON_PYBIND_CONNECTION_CONNECTION_H) to avoid collisions.
#ifndef CONNECTION_H
mssql_python/pybind/connection/connection.h:10
- Missing headers for std::wstring and std::shared_ptr. Add
#include <string>and#include <memory>.
#include "ddbc_bindings.h"
daf84f8 to
eca18a0
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.
This PR is just structure of connection class, more comprehensive review will be required to be done once we have the implementation.
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.
As discussed, we have finalized on the below approach:
- Connection is encapsulated in two classes:
- ddbc_bindings will have a _Connection class and Python will be using that class and wrap it into its own connection class
- this is being done since we want to implement connection pooling in cpp rn, eventually we can think of doing a complete migration, and eliminate python layer altogether maybe
- also, this is being done keeping in mind Cursor will also follow the same changes
Approving this under the above context
ADO Task ID [AB#34962]
This pull request introduces a new
Connectionclass for managing MSSQL database connections in themssql_pythonmodule. The class provides methods for connecting, disconnecting, handling transactions, and managing autocommit settings. Below are the key changes:Implementation of the
Connectionclass:Header file (
connection.h):Connectionclass definition, including methods for connecting (connect), disconnecting (close), transaction management (commit,rollback,end_transaction), and autocommit settings (set_autocommit,get_autocommit)._conn_strfor the connection string,_env_handleand_dbc_handlefor SQL handles, and_autocommitto track autocommit mode.Source file (
connection.cpp):Connectionclass constructor, destructor, and method stubs with logging statements for key operations like connecting, disconnecting, committing, rolling back, and managing autocommit.Checklist