This is a follow up question to a previously answered post: Is there a command line utility for validating SQLite databases in Linux?
If a database is producing the
The following fix worked to repair my database without running any command line tools.
I got the "database disk image is malformed" error message when I was working with one of my tables so I ran [PRAGMA integrity_check] which returned
Main freelist: free-page count in header is too small
On tree page 16198 cell 1: 2nd reference to page 14190
Page 16988 is never used
Page 46637 is never used
row 4493 missing from index indexname1
row 4493 missing from index indexname2
row 4493 missing from index indexname3
I first saved the schema for the table with the bad indexes so I could recreate those indexes. I then dropped the indexname 1, 2, and 3 indexes with the [drop index _] command. I exported my tables one by one to JSON files and then truncated each table. Running the integrity check at that point was successful. I then added the three indexes back with the [create index _] command and imported each table's records from their JSON file export. Running the integrity check command is still returning "ok" with all of the records restored.