[odb-users] How to enable sqlite WAL in ODB

Luke Zou luke.zou at ringcentral.com
Fri Oct 14 08:46:20 EDT 2022


Hi.


Our mobile app(iOS & android) is using the ODB, and we want to enable WAL model(https://www.sqlite.org/wal.html) .

We used following code:


auto db = std::shared_ptr<odb::sqlite::database>(new odb::sqlite::database(dbFile, SQLITE_OPEN_READWRITE | SQLITE_OPEN_CREATE | SQLITE_OPEN_SHAREDCACHE | SQLITE_OPEN_FULLMUTEX, false));

odb::transaction t(db->begin());
db->execute ("PRAGMA journal_mode=WAL");
t.commit();


But I get the exception "cannot change into wal mode from within a transaction". Try to put db->execute ("PRAGMA journal_mode=WAL"); without putting it in the transaction will also "operation can only be performed in transaction" this exception.

How can I enable WAL through ODB? Will all connections switch to WAL at the same time after opening?

thanks.


More information about the odb-users mailing list