tags:

views:

46

answers:

1

I'm using a C program with sqlite3. Some times insert works.But sometime ,its not working. assert(retval == SQLITE3_OK) gives error. while debugging I found retval value of sqlite3_step() is error code = 5 which refers to Database file is busy Even closing with sqlite3_close() return error code 5.

Any thoughts on how to close the database connection ,even when it's busy?

A: 

You could be in the middle of a transaction. Try checking http://www.sqlite.org/c3ref/get_autocommit.html for explanations on how sqlite3_get_autocommit() works. It should return a zero if it is not in auto-commit, meaning there is an open transaction.

Or if you suspect your database might still be working on something, you can use sqlite3_busy_timeout() to set a timer. http://www.sqlite.org/c3ref/busy_timeout.html

MPelletier