I'm not sure that I have a definitive answer, but having studied this a bit, I have seen numerous people who say that it is normal to leave the database open.
Also, if you look at the Sqlite website, you will see that they have done a great job of ensuring that the database is not damaged in the event of a power outage, power outage, etc.
http://www.sqlite.org/testing.html
http://www.sqlite.org/atomiccommit.html
My experience of using Sqlite and FMDB is to open the connection normally and just leave it open. Remember that this is a βconnectionβ to a file that is on the local file system, which is in flash memory. This is a completely different situation than connecting to a network. I think the probability of a failure is very subtle, since it is clearly designed to handle failures, power failures, etc. Even if they occur during the actual operation with the database - therefore, outside the operation with the database they are not a problem.
You could, of course, argue that itβs a bad practice to open a database connection when it is not in use, and I would not recommend it in a typical client-server setup, but on iPhone / iPad I find the question. Keeping it open seems to be working fine, and least of all to worry about.
source share