-
Notifications
You must be signed in to change notification settings - Fork 91
-
It would be useful to have a context manager to define transactions
from duckdb import DuckDBPyConnection class DuckDBAtomicTransaction: def __init__(self, conn: DuckDBPyConnection): self.conn = conn def __enter__(self): self.conn.begin() return self.conn def __exit__(self, exc_type, exc_value, traceback): if exc_type is None: self.conn.commit() else: self.conn.rollback() with connect() as conn: with DuckDBAtomicTransaction(conn): pass
Beta Was this translation helpful? Give feedback.
All reactions
-
👍 1
Replies: 0 comments
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment