From 2035e96b06654f3395cf01823a4f02c10f401667 Mon Sep 17 00:00:00 2001 From: Munyoki Kilyungi Date: Tue, 23 Aug 2022 13:26:58 +0300 Subject: Remove conn.commit() and conn.rollback() * gn3/db/__init__.py (update): Delete conn.commit() and conn.rollback() (insert): Ditto. * gn3/db/case_attributes.py (insert_case_attribute_audit): Ditto. (reject_case_attribute): Ditto. (approve_case_attribute): Ditto. * gn3/db/sample_data.py (update_sample_data): Ditto. (delete_sample_data): Ditto. (insert_sample_data): Ditto. --- gn3/db/__init__.py | 2 -- gn3/db/case_attributes.py | 6 ------ gn3/db/sample_data.py | 5 ----- 3 files changed, 13 deletions(-) diff --git a/gn3/db/__init__.py b/gn3/db/__init__.py index 149a344..ea800c1 100644 --- a/gn3/db/__init__.py +++ b/gn3/db/__init__.py @@ -60,7 +60,6 @@ def update(conn: Any, with conn.cursor() as cursor: cursor.execute(sql, tuple(data_.values()) + tuple(where_.values())) - conn.commit() return cursor.rowcount @@ -123,7 +122,6 @@ def insert(conn: Any, sql += ")" with conn.cursor() as cursor: cursor.execute(sql, tuple(dict_.values())) - conn.commit() return cursor.rowcount diff --git a/gn3/db/case_attributes.py b/gn3/db/case_attributes.py index 98fc58d..1d82f00 100644 --- a/gn3/db/case_attributes.py +++ b/gn3/db/case_attributes.py @@ -37,9 +37,7 @@ def insert_case_attribute_audit( ) rowcount = cursor.rowcount except Exception as _e: - conn.rollback() raise MySQLdb.Error(_e) from _e - conn.commit() return rowcount @@ -55,9 +53,7 @@ def reject_case_attribute(conn: Any, case_attr_audit_id: int) -> int: (case_attr_audit_id,), ) rowcount = cursor.rowcount - conn.commit() except Exception as _e: - conn.rollback() raise MySQLdb.Error(_e) from _e return rowcount @@ -125,8 +121,6 @@ def approve_case_attribute(conn: Any, case_attr_audit_id: int) -> int: (case_attr_audit_id,), ) rowcount = cursor.rowcount - conn.commit() except Exception as _e: - conn.rollback() raise MySQLdb.Error(_e) from _e return rowcount diff --git a/gn3/db/sample_data.py b/gn3/db/sample_data.py index d29f6c8..b67fe1c 100644 --- a/gn3/db/sample_data.py +++ b/gn3/db/sample_data.py @@ -255,9 +255,7 @@ def update_sample_data( if _rowcount: count += 1 except Exception as _e: - conn.rollback() raise MySQLdb.Error(_e) from _e - conn.commit() return count @@ -325,9 +323,7 @@ def delete_sample_data( inbredset_id=inbredset_id, ) except Exception as _e: - conn.rollback() raise MySQLdb.Error(_e) from _e - conn.commit() return count @@ -420,5 +416,4 @@ def insert_sample_data( ) return count except Exception as _e: - conn.rollback() raise MySQLdb.Error(_e) from _e -- cgit v1.2.3