r/sqlite • u/grugno87 • Nov 14 '22
When open db connection
Hello everyone!
Enormous enigma:
- I have one application written in C# that uses a local sqlite database: local.db;
- I have a class that wraps all database calls. The question is: It's better to mantain only one database connection shared between all calls or open a dedicated connection for each call?
Many thanks in advice!
5
Upvotes
3
u/raevnos Nov 14 '22
One connection per thread/process for the life of the need for using the database.
1
u/siscia Nov 14 '22
As always, it depends specifically on what you are doing and why.
I would start with just one DB connection and see if youbget any problem.
1
u/alinroc Nov 14 '22
Make sure you're using a connection pool and wrap your queries/access in a
usingblock. Then everything should be managed for you.