How to set SQLite Journal Mode to WAL?

47 views
Skip to first unread message

kim kanari

unread,
Mar 23, 2025, 1:59:29 AM3/23/25
to py4web
Hi

I understand SQLite performs faster when Journal Mode is set to WAL rather than Rollback. Rollback is the default. (Re: https://blog.sqlitecloud.io/journal-modes-in-sqlite).

How do I set it to WAL in py4web?

From my search I found the suggestion to edit DB_URI in settings.py like this ...

DB_URI = "sqlite://storage.db?journal_mode=WAL

... but it generated an error.

What's the right way to do it?

Thanks

Kim

Massimo

unread,
Mar 23, 2025, 9:13:13 PM3/23/25
to py4web
Hello Kim,

that syntax does not work with pydal but you can use explicit SQL commands to pydal. So immediately after you defined db = DAL(...) in common.py you can do:

db.executesql("pragma journal_mode=wal")

I did not test that it works. I just tested it does not break. :-)
Perhaps you can check it and confirm if this works as expected for you.

Massimo
Reply all
Reply to author
Forward
0 new messages