Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

System.data.sqlite - Activating WAL Journal Mode

I am using the System.data.sqlite.dll in my vb.net program. And for the life of me I can't figure out the code to activate WAL mode.

Do I activate this command right after I Create the DB or with every new SQLiteConnection.

And if so what code would need to be used right now im using something like:

cnn As New SQLiteConnection(String.Format("Data Source={0}\{1};PRAGMA jounal_mode=WAL;", Application.StartupPath, DBName))

is this how that PRAGMA command should be used?

like image 353
Mike Rebosse Avatar asked Dec 31 '11 02:12

Mike Rebosse


People also ask

What is SQLite journal mode?

The journal mode controls how the journal file is stored and processed. Journal files are used by SQLite to roll back transactions due to an explicit ROLLBACK command, or because an unrecoverable error was encountered (such as a constraint violation).

What is Pragma Journal_mode Wal?

PRAGMA journal_mode=WAL; The journal_mode pragma returns a string which is the new journal mode. On success, the pragma will return the string "wal".

What is System Data SQLite core?

System.Data.SQLite. The official SQLite database engine for both x86 and x64 along with the ADO.NET provider. This package includes support for LINQ and Entity Framework 6.


1 Answers

You can always use the SQLiteConnectionStringBuilder class to do the job for you:

    SQLiteConnectionStringBuilder connBuilder = new SQLiteConnectionStringBuilder();
    connBuilder.DataSource = filePath;
    connBuilder.Version = 3;
    //Set page size to NTFS cluster size = 4096 bytes
    connBuilder.PageSize = 4096;
    connBuilder.CacheSize = 10000;
    connBuilder.JournalMode = SQLiteJournalModeEnum.Wal;
    connBuilder.Pooling = true;
    connBuilder.LegacyFormat = false;
    connBuilder.DefaultTimeout = 500;
    connBuilder.Password = "yourpass";


    using(SQLiteConnection conn = new SQLiteConnection(connBuilder.ToString()))
    {
    //Database stuff
    }
like image 108
D.Rosado Avatar answered Sep 30 '22 03:09

D.Rosado