aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorFrederick Muriuki Muriithi2023-08-18 14:50:01 +0300
committerFrederick Muriuki Muriithi2023-08-18 14:50:01 +0300
commitd5d0c4718a49c5a9d26a069c5d5964d58bb324f9 (patch)
tree06bd4950e6d44556efd6c958582700ecdbec70a5
parent684d9e37381120f171aff5f9f9a58ceaefa1901e (diff)
downloadgenenetwork3-d5d0c4718a49c5a9d26a069c5d5964d58bb324f9.tar.gz
Commit on success, rollback on error.
-rw-r--r--gn3/db_utils.py3
1 files changed, 3 insertions, 0 deletions
diff --git a/gn3/db_utils.py b/gn3/db_utils.py
index 2f65a33..5fd250d 100644
--- a/gn3/db_utils.py
+++ b/gn3/db_utils.py
@@ -35,7 +35,10 @@ def database_connection(sql_uri) -> Iterator[Connection]:
port=port or 3306)
try:
yield connection
+ except mdb.Error as _mbde:
+ connection.rollback()
finally:
+ connection.commit()
connection.close()