aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorFrederick Muriuki Muriithi2023-11-22 11:41:35 +0300
committerFrederick Muriuki Muriithi2023-11-22 11:41:35 +0300
commitf680b53ab0c1d4e12b141662e2e26506efd06509 (patch)
tree97e06db8127ab3da8b2a9e8b7ec64ea228197a21
parentfeaf215b9f36c1c25a7329eed91e1fdcb068a02f (diff)
downloadgn-auth-f680b53ab0c1d4e12b141662e2e26506efd06509.tar.gz
Only commit on successful query
Only commit changes if the queries are successful.
-rw-r--r--gn_auth/auth/db/sqlite3.py2
1 files changed, 1 insertions, 1 deletions
diff --git a/gn_auth/auth/db/sqlite3.py b/gn_auth/auth/db/sqlite3.py
index 1844ca5..9849b59 100644
--- a/gn_auth/auth/db/sqlite3.py
+++ b/gn_auth/auth/db/sqlite3.py
@@ -48,12 +48,12 @@ def cursor(conn: DbConnection) -> Iterator[DbCursor]:
cur = conn.cursor()
try:
yield cur
+ conn.commit()
except sqlite3.Error as exc:
conn.rollback()
logging.debug(traceback.format_exc())
raise exc
finally:
- conn.commit()
cur.close()
def with_db_connection(func: Callable[[DbConnection], Any]) -> Any: