SQLite db. Open with Window, or Button Action ?

I have a SQLite database, around 250Mb with 7 tables.

On my Window, a number of buttons, some of which get data from the database ( usually around 500 records with an sql Select statement ) and displays in a listbox or some other function.

So is it best to ‘connect’ to the database in the window open event and close the connection when the window closes, or connect & close in the Action event for each button that needs the data ?

Pros or Cons for each ? What is the generally accepted practice ?

I normally keep connection open while app runs.
Open in app.open and let Xojo close it when app shuts down.

Also I recommend setting cache higher. For you probably a 100 MB, so most data fits into cache.

I agree with Christian except that, as an “old-school” programmer, I always explicitly close the database in the app.close event.