See https://sqlite.org/c3ref/errcode.html sqlite3_errcode() returns the latest result_code/extended_result_code, which is probably not SQLITE_OK, because you would not be calling this unless one of the API calls has returned an error. Are you checking result codes on each and every call? sqlite3_errmsg() returns a pointer to string containing the textual representation of the latest error. This is also not SQLITE_OK. Use the interface that matches your needs...