Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

sqlite3 close returns error code 5

Tags:

c

sqlite

While closing sqlite3 using sqlite3_close function it returns error code 5 5 - database file is busy. How to fix this issue.

like image 835
webminal.org Avatar asked Jan 27 '10 05:01

webminal.org


People also ask

How do you check if SQLite database is locked?

There's no use checking before (if that is possible), it still can get locked between the check and your next call. Better would be to make your call, and handle possible exceptions, eg. retry a number of times and report an error after too much retries.

How do I close a SQLite database?

close( conn ) closes the SQLite connection by using the MATLAB® interface to SQLite. The SQLite connection object remains open until you close it using the close function. Always close this object when you finish using it.

What is a SQLite_Schema error?

SQLite_Schema is an error code that is returned when there is a change in the database. The SQLite _schema error code is indicated when a prepared SQL statement is no longer valid and cannot be executed. These types of errors occur when using sqlite3 prepare () and sqlite3 step () interfaces to run SQL.


1 Answers

The sqlite3_close documenation states it clearly:

Applications must finalize all prepared statements and close all BLOB handles associated with the sqlite3 object prior to attempting to close the object. If sqlite3_close() is called on a database connection that still has outstanding prepared statements or BLOB handles, then it returns SQLITE_BUSY.

like image 73
laalto Avatar answered Sep 25 '22 11:09

laalto