add transactions and locking for certain operations (#217)

This commit is contained in:
Semisol
2023-05-15 18:09:28 +03:00
committed by GitHub
parent ddd8cebdb0
commit d4c7a15e89
2 changed files with 66 additions and 34 deletions

View File

@@ -48,6 +48,15 @@ class Compat:
elif self.type == SQLITE:
return ""
return "<nothing>"
def lock_table(self, table: str) -> str:
if self.type == POSTGRES:
return f"LOCK TABLE {table} IN EXCLUSIVE MODE;"
elif self.type == COCKROACH:
return f"LOCK TABLE {table};"
elif self.type == SQLITE:
return "BEGIN EXCLUSIVE TRANSACTION;"
return "<nothing>"
class Connection(Compat):