[odb-users] The right way to set the sqlite into WAL mode?

不明真相 52932688 at qq.com
Sun Jun 11 23:29:18 EDT 2023


Hi Boris,


I want to get the WAL mode support of SQLITE in ODB,​
​

and I use the below code piece:
​​

QScopedPointer<odb::database&gt; db(new odb::sqlite::database(DB_FILE, SQLITE_OPEN_READWRITE));&nbsp;
​​
&nbsp; &nbsp;&nbsp;
// Position 1:&nbsp; db-&gt;execute("PRAGMA journal_mode=WAL");
​

&nbsp; &nbsp; odb::transaction t(db-&gt;begin());&nbsp; &nbsp;&nbsp;


//Position 2:&nbsp; db-&gt;execute("PRAGMA journal_mode=WAL");&nbsp;&nbsp;



&nbsp; &nbsp; .........


If I use the pragama at position 1, it will give me the error:&nbsp;operation can only be performed in transaction
If I use the pragma at position 2, I will get the error:&nbsp;cannot change into wal mode from within a transaction


I viewed the post&nbsp;[odb-users] Regarding Sqlite WAL model support in ODB (codesynthesis.com), So i guess the WAL mode could be enabled in libodb, but i cannot figure out where i am wrong.


And also if you have the idea on how to set the wal mode when creating the database file please tell me.


The version of libodb is 2.5.0_b.23, and used on windows 10 system.


Best Regards


More information about the odb-users mailing list