DuckDbConnection implements Diesel’s transaction manager, so the full transaction API works. The one
DuckDB-specific caveat is savepoints — covered below.
The transaction closure
.transaction(|conn| …) runs the closure inside BEGIN/COMMIT. It commits when the closure returns
Ok, and rolls back on Err or panic:
From<diesel::result::Error>.
Rolling back explicitly
To abort without surfacing a “real” error, returnError::RollbackTransaction:
Savepoints and nesting
See the DuckDB essentials notes on the engine’s transaction model.Test transactions
For test isolation,begin_test_transaction / test_transaction are implemented: every write on a
test-transaction connection is discarded when the connection is dropped, so tests never persist state.
The core transaction! macro
See also
Core transactions
The driver-level transaction model.
DuckDB essentials
Engine behavior, including the savepoint limitation.
Pooling
Transactions are per-connection — mind pooled handles.
Insert
The writes you’ll wrap in a transaction.