SQLITE_MISUSE: bad parameter or other API misuse
The program called an SQLite function in an undefined way, such as using a statement after finalizing it. It is a bug in the calling code.
- Result code
SQLITE_MISUSE- Name
21- Category
- Primary result codes
What it means
SQLITE_MISUSE (21) means the application used the SQLite API incorrectly. SQLite tries to detect misuse but, as its documentation stresses, detection is not guaranteed, so the same bug can also crash or corrupt memory. Any SQLITE_MISUSE is a bug to fix, not a condition to handle.
Common causes
- Using a prepared statement after
sqlite3_finalize(), or a connection aftersqlite3_close(). - Sharing one connection or statement between threads without the serialized threading mode.
- Calling
sqlite3_step()again after it returned an error without resetting the statement. - Passing a NULL or invalid connection handle.
How to fix it
-
Find the call that returned the code and check the object's life cycle: prepare, bind, step, reset or finalize, and never use it after finalizing.
-
Give each thread its own connection, or open connections in serialized mode, and don't share statements across threads.
-
In higher-level bindings, look for objects used after their connection was closed, for example a cursor kept after
close().
Related errors
More primary result codes errors
SQLITE_ERRORSQL logic errorSQLITE_PERMaccess permission deniedSQLITE_ABORTquery abortedSQLITE_BUSYdatabase is lockedSQLITE_LOCKEDdatabase table is lockedSQLITE_NOMEMout of memorySQLITE_READONLYattempt to write a readonly databaseSQLITE_INTERRUPTinterrupted
The code and message text are from the SQLite result and error codes documentation. Browse the full SQLite error list or search every database error.
Work on SQLite in SQLly
A native SQL client for macOS, Windows and Linux with schema-aware IntelliSense, guardrails for risky statements and clear error messages, for SQLite and the other databases you use.