When should you close the connection to an SQLite database (using [db close] in FMDB)?
Right now I am closing it after running every batch of related queries, but should I rather close when my app closes? What are the pros/cons of doing either way?
Thanks
FMDB is an Objective-C wrapper around the C-style API provided by Apple for SQLite. It's important to note the SQLite is not an Apple proprietary technology. SQLite is an open source C-language library used by Apple, Android, Skype, and many other clients and applications to provide a robust database engine.
FMDatabase - Represents a single SQLite database. Used for executing SQL statements. FMResultSet - Represents the results of executing a query on an FMDatabase . FMDatabaseQueue - If you want to perform queries and updates on multiple threads, you'll want to use this class.
SQLite is used to develop embedded software for devices like televisions, cell phones, cameras, etc. It can manage low to medium-traffic HTTP requests. SQLite can change files into smaller size archives with lesser metadata. SQLite is used as a temporary dataset to get processed with some data within an application.
I'm the guy who wrote FMDB.
Keep it open unless you change your schema. That's the only reason to close it, and constantly re-opening it is a little hit on performance / battery life.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With