Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How set transaction isolation level to ReadUncommitted in SQLite?

According to the answer on this post it states:

Did you know that ReadUncommitted will revert to Serialized isolation unless you've enabled the shared cache and both connections are from the same thread?

Working in C#, I then went ahead and defined a DLL import as follows:

[DllImport("System.Data.SQLite.dll", CallingConvention=CallingConvention.Cdecl)]
public static extern int sqlite3_enable_shared_cache(int enable);

I called this function to enable the cache and got a successful result status of 0 when called. Nonetheless, I still get the exception "isolationlevel", when executing the below lines and attempting to set the isolation level to ReadUncommitted.

string connectionString = @"data source=d:\db\test.db3;datetimeformat=Ticks";
SQLiteConnection conn = new SQLiteConnection(connectionString);
conn.Open();
IDbTransaction tran = conn.BeginTransaction(IsolationLevel.ReadUncommitted);

This question is related to another question I posted here.

How can I pull off a query with an isolation level of ReadUncommitted in SQLite?

like image 996
Elan Avatar asked Dec 07 '25 09:12

Elan


1 Answers

To accomplish uncommitted reads see the following question and answer:

How perform SQLite query with a data reader without locking database?

like image 141
Elan Avatar answered Dec 12 '25 13:12

Elan



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!