Skip to main content

Transactions

Autocommit on by default

Every read and write operation occurs within a transaction. Any statement that reads from or writes to the database will automatically open a transaction, unless transactions are managed explicitly.

Manual transaction management

If you manually manage transactions by using BEGIN [TRANSACTION] and COMMIT [TRANSACTION]) possibly using SAVEPOINTs, the autocommit feature will be disabled and you need to explicitly COMMIT or ROLLBACK the transaction.

Ducklet uses a single database connection per SQLite database, so not closing a transaction properly will affect all other statements using that connection (even in other editor tabs).

Confirm transaction status

Ducklet will ask you whether to commit or rollback a transaction when it detects, that a transaction is still open after running your statements. But it will also allow you to manually end the transaction by running the appropriate statement.

The following SQL will trigger the confirmation dialog, asking to either commit or rollback the transaction or to leave it open:

BEGIN TRANSACTION;
CREATE TABLE wordcount_withoutrowid (
  word TEXT PRIMARY KEY,
  cnt INTEGER
) WITHOUT ROWID;

-- notice that the transaction has not been commited

Screenshot of the main Ducklet editor

Autocommit status at a glance

The editor status bar shows whether autocommit is in effect.

Screenshot of the main Ducklet editor

If you leave a transaction open without a COMMIT issued at some point, it will automatically be rolled back, when the connection is closed (e.g. when you close the Ducklet project or the Ducklet application).

References