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

旧城冷巷雨未停 提交于 2020-04-08 09:56:31

问题


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:


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


来源:https://stackoverflow.com/questions/11894941/sqlite-how-do-i-connect-to-an-in-memory-shared-cache-database

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!