I had to migrate a database from SQLite to MySQL for a project.
Here are the steps:
1. Download and install RazorSQL (from here: http://www.razorsql.com/download_mac.html)
2. Fire up RazorSQL. Go to Connections > Add Connection Profile > SQLite > Browse to your database.sqlite3 file
That should recognize the database and show you Tables, Views, Triggers and Indexes
3. Go to DB Tools > Backup > Database
4. Choose the SEMI-COLON statement separator, default encoding, browse to the file you would like to generate
5. Check all and (not surprisingly) click Generate Backup File (eg. export.sql)
6. Open the export file and do the following:
Replace AUTOINCREMENT with AUTO_INCREMENT
Delete all ” characters (or replace them with a space)
Delete any line with ‘sqlite’ in it. (eg. CREATE TABLE sqlite_sequence(name,seq);)
Replace all “boolean DEFAULT ‘f’” with “boolean DEFAULT false”
Replace all “boolean DEFAULT ‘t’” with “boolean DEFAULT true”
Or… Run this Ruby script: sqlite3_to_mysql.converter.rb
7. With your .sql file, fire up the Terminal and run mysql –user=your_db_user –password=your_password –database=your_mysql_database < export.sql
You’re done!
(Thanks to Max Page for this article, which helped me a lot.)
