mirror of
https://github.com/aljazceru/turso.git
synced 2025-12-17 08:34:19 +01:00
antithesis: Fix transaction management
Commit 5216e67d ("bindings/python: Start transaction implicitly in
execute()") fixed transaction management in Python bindings, which means
we now need to execute explicit commit().
This commit is contained in:
@@ -50,3 +50,5 @@ cur.execute(f"""
|
|||||||
INSERT INTO initial_state (num_accts, total)
|
INSERT INTO initial_state (num_accts, total)
|
||||||
VALUES ({num_accts}, {total})
|
VALUES ({num_accts}, {total})
|
||||||
""")
|
""")
|
||||||
|
|
||||||
|
con.commit()
|
||||||
|
|||||||
@@ -83,4 +83,6 @@ for i in range(tbl_count):
|
|||||||
CREATE TABLE tbl_{i} ({cols_str})
|
CREATE TABLE tbl_{i} ({cols_str})
|
||||||
""")
|
""")
|
||||||
|
|
||||||
|
con.commit()
|
||||||
|
|
||||||
print(f"DB Schemas\n------------\n{json.dumps(schemas, indent=2)}")
|
print(f"DB Schemas\n------------\n{json.dumps(schemas, indent=2)}")
|
||||||
|
|||||||
@@ -37,6 +37,13 @@ print(f"Attempt to delete {deletions} rows in tbl_{selected_tbl}...")
|
|||||||
for i in range(deletions):
|
for i in range(deletions):
|
||||||
where_clause = f"col_{pk} = {generate_random_value(tbl_schema[f'col_{pk}']['data_type'])}"
|
where_clause = f"col_{pk} = {generate_random_value(tbl_schema[f'col_{pk}']['data_type'])}"
|
||||||
|
|
||||||
cur.execute(f"""
|
try:
|
||||||
DELETE FROM tbl_{selected_tbl} WHERE {where_clause}
|
cur.execute(f"""
|
||||||
""")
|
DELETE FROM tbl_{selected_tbl} WHERE {where_clause}
|
||||||
|
""")
|
||||||
|
except turso.OperationalError:
|
||||||
|
con.rollback()
|
||||||
|
# Re-raise other operational errors
|
||||||
|
raise
|
||||||
|
|
||||||
|
con.commit()
|
||||||
|
|||||||
@@ -44,5 +44,8 @@ for i in range(insertions):
|
|||||||
# Ignore UNIQUE constraint violations
|
# Ignore UNIQUE constraint violations
|
||||||
pass
|
pass
|
||||||
else:
|
else:
|
||||||
|
con.rollback()
|
||||||
# Re-raise other operational errors
|
# Re-raise other operational errors
|
||||||
raise
|
raise
|
||||||
|
|
||||||
|
con.commit()
|
||||||
|
|||||||
@@ -58,5 +58,8 @@ for i in range(updates):
|
|||||||
# Ignore UNIQUE constraint violations
|
# Ignore UNIQUE constraint violations
|
||||||
pass
|
pass
|
||||||
else:
|
else:
|
||||||
|
con.rollback()
|
||||||
# Re-raise other operational errors
|
# Re-raise other operational errors
|
||||||
raise
|
raise
|
||||||
|
|
||||||
|
con.commit()
|
||||||
|
|||||||
Reference in New Issue
Block a user