I have an export SQL file containing tables and data from MySQL and I want to import it into a Sqlite 3 DB.
What is the best way to do that?
Just importing t
I had an issue with the mysql db being ISO-8859-1 (Latin-1). When did the conversion to sqlite3 assumed the data was UTF-8 resulting in decoding errors.
It was easy to fix with this:
iconv -f ISO-8859-1 -t UTF-8 mysql_dump_file > mysql_dump_file_utf8
Incase this helps someone.
This is the best written and well documented shell Script to convert ssql to .db
https://gist.github.com/esperlu/943776
or better use this tools It's amazing and fast ESF Database Migration Toolkit .
after having tried all the script here it didn't work until i did use the esf tool .
Note :
Trial version add a 'T' to the begingn of each text value you have But the pro version worked like a charm :)
At least, with mysql 5.0.x, I had to remove collate utf8_unicode_ci from mysql's dump before importing it to sqlite3. So I modified the script to include the following to the list of seds:
sed 's/ collate utf8_unicode_ci/ /g' |
Update:
MySQL treats boolean fields as "tinyint(1)", so I had to add the following before tinyint([0-9]*)
sed:
sed 's/ tinyint(1) / boolean /g' |
Also, since I'm trying to replicate a mysql db (production) to a sqlite3 db (development) of a Ruby On Rails application, I had to add the following line in order to set an auto-incrementing primary key:
sed 's/) NOT NULL/) PRIMARY KEY AUTOINCREMENT NOT NULL/g' |
I'm still trying to figure out a way to change the KEY entries from mysql to its corresponding CREATE INDEX entry of sqlite3.