Skip to content

Commit 91f9c5d

Browse files
author
Saumya Garg
committed
adding comments
1 parent 9246911 commit 91f9c5d

File tree

2 files changed

+24
-3
lines changed

2 files changed

+24
-3
lines changed

mssql_python/pybind/connection/connection.cpp

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,10 @@
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

mssql_python/pybind/connection/connection.h

Lines changed: 20 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,24 +6,41 @@
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+
913
class Connection {
1014
public:
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

2239
private:
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;

0 commit comments

Comments
 (0)