8

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?

1 Answer 1

21

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
Sign up to request clarification or add additional context in comments.

3 Comments

I have the version 1.0.99 and it must be with ToFullPath: FullUri=file::memory:?cache=shared;ToFullPath=false.
We could not get "FullUri" to work with Sqlite but found the solution here: forums.devart.com/viewtopic.php?t=26312#p119530: "DataSource=file:memdb1?mode=memory&cache=shared"
Thank you very much! This helped a lot! I modified your solution a little, and used the following, that additionally provides a name for a database: FullUri=file:memdb_name?mode=memory&cache=shared . This can be then attached by ATTACH DATABASE 'file:memdb_name?mode=memory&cache=shared' as sharedInMemoryDB;

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.