Basic question on SQLiteDatabases

When I connect to a file-based SQLiteDatabase db, what’s common practice:
a) Check with db.connect every time before I run an SQL statement
b) Do db.connect once when I start the app and it will never disconnect.

I mean, the real question is, will a file-based SQLiteDatabase ever disconnect, for example, when the user exits the app and comes back later?

For a SQLite database b is the answer and this is consistent on all platforms but not for all database engines.

1 Like

When the user exit the app the connection will be closed automatically.

For my Preferences database file I connect in the Open event and leave it open, never closing it until the app closes.

1 Like

So, if I understand properly, it’s like this: only if the app is being closed completely, i.e., it is not open any longer in the background (task manager), only then will the database disconnect.

As long as the user exits the app but the app is still accessible through the task manager, the database connection is also still there. Which means, as you both say, I will only connect to the database file in the App.Open event handler.

Thank you!