aboutsummaryrefslogtreecommitdiff
path: root/wqflask
diff options
context:
space:
mode:
authorFrederick Muriuki Muriithi2023-07-26 09:52:11 +0300
committerFrederick Muriuki Muriithi2023-07-26 11:24:42 +0300
commitbc6108f83fa99a69752778253761d763a0b99db4 (patch)
tree375646ee4b07d57f7ec1819a584143644197b639 /wqflask
parent562413ba51fa64b3cdb340d54c888ca555004e06 (diff)
downloadgenenetwork2-bc6108f83fa99a69752778253761d763a0b99db4.tar.gz
Commit changes on success, rollback on failure.
Ensure that changes the database are committed if the query is successful, or rolled back if not.
Diffstat (limited to 'wqflask')
-rw-r--r--wqflask/wqflask/database.py4
1 files changed, 4 insertions, 0 deletions
diff --git a/wqflask/wqflask/database.py b/wqflask/wqflask/database.py
index ad2d8216..0c1fddf1 100644
--- a/wqflask/wqflask/database.py
+++ b/wqflask/wqflask/database.py
@@ -40,5 +40,9 @@ def database_connection(sql_uri: str) -> Iterator[Connection]:
)
try:
yield connection
+ connection.commit()
+ except Exception as _exc:
+ connection.rollback()
+ raise _exc
finally:
connection.close()