SQLPyHelper 0.1.9__py3-none-any.whl → 0.2.0__py3-none-any.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- sqlpyhelper/__init__.py +1 -1
- sqlpyhelper/db_helper.py +9 -5
- {sqlpyhelper-0.1.9.dist-info → sqlpyhelper-0.2.0.dist-info}/METADATA +1 -1
- sqlpyhelper-0.2.0.dist-info/RECORD +13 -0
- sqlpyhelper-0.1.9.dist-info/RECORD +0 -13
- {sqlpyhelper-0.1.9.dist-info → sqlpyhelper-0.2.0.dist-info}/WHEEL +0 -0
- {sqlpyhelper-0.1.9.dist-info → sqlpyhelper-0.2.0.dist-info}/entry_points.txt +0 -0
- {sqlpyhelper-0.1.9.dist-info → sqlpyhelper-0.2.0.dist-info}/licenses/LICENSE +0 -0
- {sqlpyhelper-0.1.9.dist-info → sqlpyhelper-0.2.0.dist-info}/top_level.txt +0 -0
sqlpyhelper/__init__.py
CHANGED
sqlpyhelper/db_helper.py
CHANGED
|
@@ -80,6 +80,7 @@ class SQLPyHelper:
|
|
|
80
80
|
self.port: Optional[str] = port or os.getenv("DB_PORT")
|
|
81
81
|
self.oracle_sid: Optional[str] = oracle_sid or os.getenv("ORACLE_SID")
|
|
82
82
|
self.pool: Any = None
|
|
83
|
+
self._in_transaction: bool = False
|
|
83
84
|
|
|
84
85
|
if not self.db_type or not self.database:
|
|
85
86
|
raise ValueError("Missing required database configuration.")
|
|
@@ -143,14 +144,14 @@ class SQLPyHelper:
|
|
|
143
144
|
self.cursor.execute(query, params)
|
|
144
145
|
else:
|
|
145
146
|
self.cursor.execute(query)
|
|
146
|
-
self.
|
|
147
|
+
if not self._in_transaction:
|
|
148
|
+
self.connection.commit()
|
|
147
149
|
except Exception as e:
|
|
148
|
-
if "server has gone away" in str(
|
|
149
|
-
e
|
|
150
|
-
): # Example check for MySQL lost connection
|
|
150
|
+
if "server has gone away" in str(e):
|
|
151
151
|
self.reconnect()
|
|
152
152
|
self.cursor.execute(query, params) # type: ignore[arg-type]
|
|
153
|
-
self.
|
|
153
|
+
if not self._in_transaction:
|
|
154
|
+
self.connection.commit()
|
|
154
155
|
else:
|
|
155
156
|
raise QueryError(f"Query failed: {e}") from e
|
|
156
157
|
|
|
@@ -350,6 +351,7 @@ class SQLPyHelper:
|
|
|
350
351
|
self.execute_query("BEGIN TRANSACTION")
|
|
351
352
|
elif self.db_type == "oracle":
|
|
352
353
|
pass # Oracle starts transactions implicitly on first DML statement
|
|
354
|
+
self._in_transaction = True
|
|
353
355
|
logger.info("Transaction started on %s database", self.db_type)
|
|
354
356
|
except Exception as e:
|
|
355
357
|
raise QueryError(f"Failed to begin transaction: {e}") from e
|
|
@@ -358,6 +360,7 @@ class SQLPyHelper:
|
|
|
358
360
|
"""Commit the current transaction."""
|
|
359
361
|
try:
|
|
360
362
|
self.connection.commit()
|
|
363
|
+
self._in_transaction = False
|
|
361
364
|
logger.info("Transaction committed on %s database", self.db_type)
|
|
362
365
|
except Exception as e:
|
|
363
366
|
raise QueryError(f"Failed to commit transaction: {e}") from e
|
|
@@ -366,6 +369,7 @@ class SQLPyHelper:
|
|
|
366
369
|
"""Roll back the current transaction."""
|
|
367
370
|
try:
|
|
368
371
|
self.connection.rollback()
|
|
372
|
+
self._in_transaction = False
|
|
369
373
|
logger.info("Transaction rolled back on %s database", self.db_type)
|
|
370
374
|
except Exception as e:
|
|
371
375
|
raise QueryError(f"Failed to rollback transaction: {e}") from e
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
sqlpyhelper/__init__.py,sha256=zxVPeEAfG2pTAxvjU6D_U6x4ef4YMg4NqNFr-6SoSK0,370
|
|
2
|
+
sqlpyhelper/async_helper.py,sha256=beq0wKxDl7Qv-CW_qA1-h_DPhDpC1CQHdstnKO-4FSI,21473
|
|
3
|
+
sqlpyhelper/automation_utils.py,sha256=pC6pH6bJ-k8iPVeHJ4gUiwEe822dasmKg53ya9bMxyE,5381
|
|
4
|
+
sqlpyhelper/cli.py,sha256=yj0kWJu3oh_JLnmi0L7a5ing2_0x4CQGOKSOhZLAtoY,5646
|
|
5
|
+
sqlpyhelper/db_helper.py,sha256=zRZGidneQspAhYekD7ACvn9nim3ylYav_ObbCLxRXaM,14409
|
|
6
|
+
sqlpyhelper/migration.py,sha256=byAn7ToVgIB8tl1N39DB0MbHigjH2l-qX7QSskgzzTg,11673
|
|
7
|
+
sqlpyhelper/py.typed,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
8
|
+
sqlpyhelper-0.2.0.dist-info/licenses/LICENSE,sha256=9XzXxZ_8mWFM9-2TlqyE3L69zvRf4VPY_xIzSj5iU-g,1076
|
|
9
|
+
sqlpyhelper-0.2.0.dist-info/METADATA,sha256=mI3df5g2wPddtecAYNcq95ipzwoXyHA15b2UhAuj300,11607
|
|
10
|
+
sqlpyhelper-0.2.0.dist-info/WHEEL,sha256=aeYiig01lYGDzBgS8HxWXOg3uV61G9ijOsup-k9o1sk,91
|
|
11
|
+
sqlpyhelper-0.2.0.dist-info/entry_points.txt,sha256=uAzSqwkAbbJqQUKHlPNwOebTJVA0FqkOvn2CRP6xSz8,52
|
|
12
|
+
sqlpyhelper-0.2.0.dist-info/top_level.txt,sha256=FrLqTmqTGDa8jHnnf2ZVkYO-gFvLXX9QonpUCE6wKGs,12
|
|
13
|
+
sqlpyhelper-0.2.0.dist-info/RECORD,,
|
|
@@ -1,13 +0,0 @@
|
|
|
1
|
-
sqlpyhelper/__init__.py,sha256=8oatB3lhbYVLzbkCIDrlE1mTJVljs2GeNuUG34_vYd0,370
|
|
2
|
-
sqlpyhelper/async_helper.py,sha256=beq0wKxDl7Qv-CW_qA1-h_DPhDpC1CQHdstnKO-4FSI,21473
|
|
3
|
-
sqlpyhelper/automation_utils.py,sha256=pC6pH6bJ-k8iPVeHJ4gUiwEe822dasmKg53ya9bMxyE,5381
|
|
4
|
-
sqlpyhelper/cli.py,sha256=yj0kWJu3oh_JLnmi0L7a5ing2_0x4CQGOKSOhZLAtoY,5646
|
|
5
|
-
sqlpyhelper/db_helper.py,sha256=SrXro_-ki5AT_Yj6u1k5-aUZYq-d2QXeQPXURXqUMLk,14223
|
|
6
|
-
sqlpyhelper/migration.py,sha256=byAn7ToVgIB8tl1N39DB0MbHigjH2l-qX7QSskgzzTg,11673
|
|
7
|
-
sqlpyhelper/py.typed,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
8
|
-
sqlpyhelper-0.1.9.dist-info/licenses/LICENSE,sha256=9XzXxZ_8mWFM9-2TlqyE3L69zvRf4VPY_xIzSj5iU-g,1076
|
|
9
|
-
sqlpyhelper-0.1.9.dist-info/METADATA,sha256=TTa0zKb4o_Zuf9x1j63Xg15vE9rUBbgDUnSjJHi0Hq0,11607
|
|
10
|
-
sqlpyhelper-0.1.9.dist-info/WHEEL,sha256=aeYiig01lYGDzBgS8HxWXOg3uV61G9ijOsup-k9o1sk,91
|
|
11
|
-
sqlpyhelper-0.1.9.dist-info/entry_points.txt,sha256=uAzSqwkAbbJqQUKHlPNwOebTJVA0FqkOvn2CRP6xSz8,52
|
|
12
|
-
sqlpyhelper-0.1.9.dist-info/top_level.txt,sha256=FrLqTmqTGDa8jHnnf2ZVkYO-gFvLXX9QonpUCE6wKGs,12
|
|
13
|
-
sqlpyhelper-0.1.9.dist-info/RECORD,,
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|