Skip to content

Instantly share code, notes, and snippets.

@amochohan
Created October 6, 2015 09:28
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save amochohan/fc22bd5081d723f77c71 to your computer and use it in GitHub Desktop.
Save amochohan/fc22bd5081d723f77c71 to your computer and use it in GitHub Desktop.
Convert an SQLite database to MySQL dump - fix malformed database error

Fix a malformed SQLite database

From time to time, when running integration tests you'll notice that tests that worked previously have stopped working. Trying to modify the schema of an SQLite database is throwing an error. The dreaded:

Error (11) malformed database

Fortunately, there's quite an easy fix. Simply head to the command line, and use the following commands:

sqlite3 yourdatabase.sqlite .mode insert .output schema.sql .dump .exit

You now how a full sql dump of your sqlite database's schema (and contents). Open up the new schema.sql file and fix any issues that you can see. For me, I noticed that there was a mismatch of ` and " characters.

If you're using OSX, use sqlitebrowser to simply execute the new cleaned SQL and save the new database file.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment