-
Jun 8th, 2021, 11:38 PM
#1
Thread Starter
New Member
Pragma wal/wal2
I'm using VS 2019 16.9.4 and I'm writing a database program using SQLite. I'm not sure how concurrent writing and reading to and from database is handled by default. I have read the SQLite WAL modes notes, but I still don't quite understand.
By default is journaling enabled?
Is this how you enable WAL2?
Public connectionString As String = String.Format("Data Source = {0}; PRAGMA journal_mode=WAL2", dtBasePath)
Thanks for the help.
-
Jun 9th, 2021, 01:07 AM
#2
Thread Starter
New Member
Re: Pragma wal/wal2
Originally Posted by vkohli
I'm using VS 2019 16.9.4 and I'm writing a database program using SQLite. I'm not sure how concurrent writing and reading to and from database is handled by default. I have read the SQLite WAL modes notes, but I still don't quite understand.
By default is journaling enabled?
Is this how you enable WAL2?
Public connectionString As String = String.Format("Data Source = {0}; PRAGMA journal_mode=WAL2", dtBasePath)
Thanks for the help.
I figured it out. Assume your database name is dBase.
Remove PRAGMA from the connectionString. So it should read:
..("Data Source = {0}; journal_mode=WAL2", ...)
It will create both a dBase-wal and dBase-shm.
-
Jun 9th, 2021, 01:40 AM
#3
Re: Pragma wal/wal2
OT: every ADO.NET provider has a class dedicated to building connection strings. If you're using SQLite then your provider will have a SqliteConnectionStringBuilder class and I would recommend using it. It's a neater and less error-prone way to build provider-specific connection strings in code.
-
Jun 9th, 2021, 09:15 AM
#4
Thread Starter
New Member
Re: Pragma wal/wal2
Originally Posted by jmcilhinney
OT: every ADO.NET provider has a class dedicated to building connection strings. If you're using SQLite then your provider will have a SqliteConnectionStringBuilder class and I would recommend using it. It's a neater and less error-prone way to build provider-specific connection strings in code.
Thanks for the suggestion. I'll take a look at string builder. I did notice that once the journal mode of the database is set to WAL/WAL2 it is persistent. So it only needs to be set once. To roll back you will have to set the journal mode to DELETE.
-
Jun 15th, 2021, 05:54 AM
#5
Re: Pragma wal/wal2
OT2:
regarding the Pragma: IIRC, you can fire off a PRAGMA against SQLite (after connection is established) like an SQL-Statement
Last edited by Zvoni; Tomorrow at 31:69 PM.
----------------------------------------------------------------------------------------
One System to rule them all, One Code to find them,
One IDE to bring them all, and to the Framework bind them,
in the Land of Redmond, where the Windows lie
---------------------------------------------------------------------------------
People call me crazy because i'm jumping out of perfectly fine airplanes.
---------------------------------------------------------------------------------
Code is like a joke: If you have to explain it, it's bad
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|