journalMode

Queries or sets the journal mode for the database.

The journal mode determines the strategy SQLite uses to implement atomic commit and rollback. Different modes offer trade-offs between performance, durability, and concurrency.

The value is a JournalMode enum, which corresponds to the following SQLite modes:

  • JournalMode.DELETE: The default mode. The journal file is deleted at the end of each transaction.

  • JournalMode.TRUNCATE: The journal file is truncated to zero-length instead of being deleted.

  • JournalMode.PERSIST: The journal file is left in place, but its header is overwritten to mark it as committed.

  • JournalMode.MEMORY: The journal is stored in memory, not on disk. Faster but not durable against crashes.

  • JournalMode.WAL: (Write-Ahead Logging) Offers higher concurrency by allowing readers to operate while a writer is active. This is often the recommended mode for modern applications.

  • JournalMode.OFF: Disables the rollback journal completely. This can improve speed but means a crash or power loss can corrupt the database.

Changing the journal mode is an atomic operation.

Author

MOHAMMAD AZIM ANSARI

See also