SQLITE_NOTADB: file is not a database
The file opened doesn't look like an SQLite database: it's another kind of file, it's encrypted, or its header is damaged.
- Result code
SQLITE_NOTADB- Name
26- Category
- Primary result codes
What it means
SQLITE_NOTADB (26) means the file's header doesn't match SQLite's format. Every SQLite database starts with the 16 bytes SQLite format 3 followed by a zero byte. Opening a file only reads it lazily, so the error usually appears on the first query rather than at open time.
Common causes
- The path points at a different kind of file, such as a CSV, a SQL dump or a database from another engine.
- The database is encrypted (SQLCipher or another encryption extension) and was opened without the key, or with a library that has no encryption support.
- The file was damaged at the start, for example by an interrupted download or copy.
- A text SQL dump was given where a database file was expected; load it with the shell instead.
How to fix it
-
Check the first bytes of the file. On macOS or Linux:
head -c 16 app.dbshould printSQLite format 3. -
If the database is encrypted, open it with the matching library and key.
-
If the file is a SQL dump, build a database from it:
sqlite3 new.db < dump.sql. -
If the header is damaged, try the
.recovercommand or restore a backup.
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.