Cleanup for _start_transaction_under_autocommit

This commit is contained in:
tcely authored and GitHub committed 2024-12-12 09:03:08 -05:00
1 parent de52e55e34
commit 21e9cbef4b
1 file changed
+6 -7
+6 -7
View File
@@ -5,15 +5,14 @@ class DatabaseWrapper(base.DatabaseWrapper):
def _start_transaction_under_autocommit(self):
conn_params = self.get_connection_params()
if "transaction_mode" not in conn_params:
self.cursor().execute("BEGIN TRANSACTION")
else:
transaction_modes = frozenset(["DEFERRED", "EXCLUSIVE", "IMMEDIATE"])
sql_statement = "BEGIN TRANSACTION"
if "transaction_mode" in conn_params:
tm = str(conn_params["transaction_mode"]).upper().strip()
transaction_modes = frozenset(["DEFERRED", "EXCLUSIVE", "IMMEDIATE"])
if tm in transaction_modes:
self.cursor().execute(f"BEGIN {tm} TRANSACTION")
else:
self.cursor().execute("BEGIN TRANSACTION")
sql_statement = f"BEGIN {tm} TRANSACTION"
self.cursor().execute(sql_statement)
def init_connection_state(self):