[odb-users] The right way to set the sqlite into WAL mode?
Boris Kolpackov
boris at codesynthesis.com
Fri Jun 16 04:41:18 EDT 2023
不明真相 <52932688 at qq.com> writes:
> QScopedPointer<odb::database> db(new odb::sqlite::database(DB_FILE, SQLITE_OPEN_READWRITE));
>
>
> // Position 1: db->execute("PRAGMA journal_mode=WAL");
>
>
> odb::transaction t(db->begin());
>
>
> //Position 2: db->execute("PRAGMA journal_mode=WAL");
>
>
> If I use the pragama at position 1, it will give me the error: operation can only be performed in transaction
> If I use the pragma at position 2, I will get the error: cannot change into wal mode from within a transaction
The correct way is to first get the connection and then execute the pragma
on that:
db->connection ()->execute ("PRAGMA journal_mode=WAL");
More information about the odb-users
mailing list