I am confused about database open and close operation for FMDB wrapper class.
Is it creating issue if i open database in applicationDidFinishLoading method of AppDelegate class and do not close until application will terminate ?
Thanks.
There's no reason to close it unless you change the schema. So keep it open.
From the Official FMDB documentation:
Opening
Before you can interact with the database, it must be opened. Opening fails if there are insufficient resources or permissions to open and/or create the database.
if (![db open]) {
[db release];
return;
}
Closing
When you have finished executing queries and updates on the database, you should close the FMDatabase connection so that SQLite will relinquish any resources it has acquired during the course of its operation.
[db close];
So, every time your query the Database, you should have a pair of open
and close
calls on your database.
In short, open a DB connection when you require things from database and close it when you are done using the database.
Link to documentation : https://github.com/ccgus/fmdb
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