From f680b53ab0c1d4e12b141662e2e26506efd06509 Mon Sep 17 00:00:00 2001 From: Frederick Muriuki Muriithi Date: Wed, 22 Nov 2023 11:41:35 +0300 Subject: Only commit on successful query Only commit changes if the queries are successful. --- gn_auth/auth/db/sqlite3.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'gn_auth/auth/db/sqlite3.py') 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: -- cgit v1.2.3