Key facts
- Binary format that starts with the 16-byte header "SQLite format 3" followed by a null byte; also uses the extensions .sqlite3 and .db.
- MIME type is application/vnd.sqlite3 (application/x-sqlite3 is also seen).
- Supports databases up to hundreds of terabytes, though most are a few KB to a few GB.
- In WAL mode the database has companion -wal and -shm files that hold recent changes and must be kept with it.
- Created by apps through the SQLite library; no separate database server is needed.
How to open a .sqlite file
Open it with the free DB Browser for SQLite or DBeaver, or with sqlite3.exe from sqlite.org: sqlite3 database.sqlite.
macOS includes the sqlite3 command, so run sqlite3 database.sqlite in Terminal, or use DB Browser for SQLite or TablePlus for a graphical view.
Install the sqlite3 package and run sqlite3 database.sqlite, then .tables to list tables and SELECT queries to read data.
Common problems and fixes
- "database disk image is malformed"
- The file is corrupted, often from copying it while in use or a crash. Work on a copy and run sqlite3 broken.sqlite ".recover" | sqlite3 fixed.sqlite to salvage what can be read.
- "database is locked"
- Another process holds a write lock, or a crashed process left one open. Close other apps using the file, set a busy timeout in your code, and avoid storing it on network drives.
- Recent changes are missing after copying the file
- In WAL mode the newest data may still be in the -wal file. Copy the -wal and -shm files too, or run PRAGMA wal_checkpoint(TRUNCATE); before copying.
- "file is not a database" (SQLITE_NOTADB)
- The file is encrypted (for example with SQLCipher), is empty, or is not SQLite at all. Check the first bytes for the SQLite header and open encrypted files only with the matching key and tool.
- "attempt to write a readonly database"
- The process lacks write permission on the file or its folder, which SQLite needs for journal files. Give the web or app user write access to both.
Often converted to or from: SQL dump, CSV, JSON, MySQL, PostgreSQL