Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

SQLite pragma (journal_mode) statement persistence

Tags:

sqlite

Let's say that I have a script called schema.sql which is used to allocate a new SQLite db with my desired schema.

If this script contains PRAGMA journal_mode = 'wal'; before any DML, is the database continually set to WAL mode? Or is journal mode something that needs to be configured on each connection/command?

like image 619
pim Avatar asked Jun 11 '26 23:06

pim


1 Answers

The journal mode is only persisted for WAL mode. From the docs:

Unlike the other journaling modes, PRAGMA journal_mode=WAL is persistent. If a process sets WAL mode, then closes and reopens the database, the database will come back in WAL mode. In contrast, if a process sets (for example) PRAGMA journal_mode=TRUNCATE and then closes and reopens the database will come back up in the default rollback mode of DELETE rather than the previous TRUNCATE setting.

like image 72
Jacob McDowell Avatar answered Jun 15 '26 00:06

Jacob McDowell