Transactions¶
db.transaction() returns a context manager. Writes inside the block are
buffered in memory and committed atomically via a write-ahead journal. An
exception inside the block rolls everything back.
transaction
¶
Transactions.
A transaction acquires the database-wide write lock for its full duration and buffers all modified table states in memory. On commit it writes a write-ahead journal durably first (the commit point), then applies each touched table file, then removes the journal. A crash after the journal is durable but before all tables are applied is recovered on the next open by replaying the journal.
Every single-op mutation is wrapped as an implicit one-table transaction, so multi-table cascades (e.g. a cascading delete) are all-or-nothing too.
Nested transactions are not supported and raise :class:TransactionError.
Transaction
¶
An in-memory transaction with copy-on-first-touch buffering.
Commit is durable and all-or-nothing across table files via the journal: journal fsync is the commit point, then each table is applied, then the journal is removed. Rollback discards the buffer without touching files.