1

In a WPF app, I'm creating a connection to a local encrypted database (using Microsoft.Data.Sqlite):

string builder = new SqliteConnectionStringBuilder($"Data Source=source.sqlite; Password='{password}';")
{
   Mode = SqliteOpenMode.ReadOnly
}.ToString();

Each query is wrapped in a using block.

The problem is that after 5 to 10 minutes of inactivity on the app, SQLite seems to close the connection to the database as the next query takes as long as the first one (when opening the app, which is normal, I guess).

I tried playing with the parameters of the SqliteConnectionStringBuilder such as Cache or Pooling, but no success.

Would it be possible to prevent this from happening?

ASh
  • 34,632
  • 9
  • 60
  • 82
difilo9635
  • 19
  • 1
  • After a brief search around, I haven't found a parameter to somehow mitigate this. But my first instict would be to just set up a reoccurring timer to , say 3 minutes and just issue a NOP Query to keep the connection open. So basically a manual keep-alive. – Fildor Jun 03 '22 at 08:01

0 Answers0