Skip to content
TaskBionics

How to fix "database disk image is malformed" in apps, DB Browser for SQLite

sqlite3.DatabaseError: database disk image is malformed

What this error means

SQLite's integrity checks found damaged pages.

Why it happens

  • Power loss during a write
  • Copying the database while an app had it open
  • Deleting the -wal or -journal file

How to fix it

  1. Copy the database together with its -wal and -shm files before trying anything
  2. With the sqlite3 tool: sqlite3 broken.db ".recover" | sqlite3 fixed.db
  3. Or upload it here to recover every readable row automatically

About SQLite database files

SQLite stores a whole database in one file of fixed-size pages. Damage to a few pages makes SQLite refuse the entire database, but rows on healthy pages can still be read and copied out.

Other SQLITE errors