Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

When to close SQLite database (using FMDB)

Tags:

sqlite

fmdb

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

like image 333
Souleiman Avatar asked Mar 30 '13 15:03

Souleiman


People also ask

What is FMDB?

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.

What is FMDatabase?

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.

What is SQLite used for?

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.


1 Answers

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.

like image 104
ccgus Avatar answered Oct 23 '22 17:10

ccgus