daniel too

Mar 13
Permalink

Translating a database from MySQL to SQLite

I needed to translate some data from MySQL to SQLite on OSX today, and it proved to be a little more work than I thought. This is the procedure I went through to get it done:

Used CPAN to install SQLFairy with the command:

sudo cpan -i SQL::Translator

exported the MySQL database schema with no data in it

mysqldump -u username -p database --no-data > database.sql 

translate it into sqlite

sqlt -f MySQL -t SQLite database.sql > database.sqlite 

import that in sqlite:

sqlite3 database.db
.read database.sqlite

I then took my MySQL .sql dumps, removed the code all the way up to the INSERT statements then read that into sqlite also

.read dump.sql

There’s possibly a better way to do this, but I’m not exactly an expert =)