Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

SQLite: How do I connect to an in-memory, shared cache database?

I'm trying out the in-memory shared cache feature of SQLite 3.7.13, via the ADO.NET provider. The following connect string works, but yields a non-shared-cache db:

Data Source=:memory:

When I try any of these:

Data Source=:memory:?cache=shared
Data Source=file::memory:?cache=shared
Data Source=file:x?mode=memory&cache=shared

I get the following ArgumentException when opening a connection:

Invalid ConnectionString format for parameter "Data Source"

What should the connect string look like for SQLite in-memory shared-cache databases?

like image 553
lesscode Avatar asked Aug 10 '12 03:08

lesscode


1 Answers

It looks like although the shared cache feature was in SQLite, the latest (1.0.81.0) version of System.Data.SQLite at the time didn't yet support the FullUri feature. Looks like the 1.0.82.0 version works, and the connection string should be:

FullUri=file::memory:?cache=shared
like image 86
lesscode Avatar answered Sep 23 '22 22:09

lesscode