File tree Expand file tree Collapse file tree 2 files changed +24
-3
lines changed
mssql_python/pybind/connection Expand file tree Collapse file tree 2 files changed +24
-3
lines changed Original file line number Diff line number Diff line change 11// Copyright (c) Microsoft Corporation.
22// Licensed under the MIT license.
33
4+ // Implements the Connection class declared in connection.h.
5+ // This class wraps low-level ODBC operations like connect/disconnect,
6+ // transaction control, and autocommit configuration.
7+
48#include " connection.h"
59#include < iostream>
610
Original file line number Diff line number Diff line change 66
77#include " ddbc_bindings.h"
88
9+ // Represents a single ODBC database connection.
10+ // Manages its own environment and connection handles.
11+ // Note: This class does NOT implement pooling logic directly.
12+
913class Connection {
1014public:
1115 Connection (const std::wstring& conn_str);
1216 ~Connection ();
1317
18+ // Establish the connection using the stored connection string.
1419 SQLRETURN connect ();
20+
21+ // Close the connection and free resources.
1522 SQLRETURN close ();
23+
24+ // Commit the current transaction.
1625 SQLRETURN commit ();
26+
27+ // Rollback the current transaction.
1728 SQLRETURN rollback ();
29+
30+ // End the transaction with the specified completion type.
1831 SQLRETURN end_transaction (SQLSMALLINT completion_type);
32+
33+ // Enable or disable autocommit mode.
1934 SQLRETURN set_autocommit (bool value);
35+
36+ // Check whether autocommit is enabled.
2037 bool get_autocommit () const ;
2138
2239private:
2340
24- std::wstring _conn_str;
25- SqlHandlePtr _env_handle;
26- SqlHandlePtr _dbc_handle;
41+ std::wstring _conn_str; // Connection string
42+ SqlHandlePtr _env_handle; // Environment handle
43+ SqlHandlePtr _dbc_handle; // Connection handle
2744
2845 bool _autocommit = false ;
2946 std::shared_ptr<Connection> _conn;
You can’t perform that action at this time.
0 commit comments