MySQL Forums
Forum List  »  SQLite

SQLite Migration - Converter tools
Posted by: alexey petrovsky
Date: May 28, 2006 01:36AM

http://www.sqlite.org/cvstrac/wiki?p=ConverterTools

Please, read the possible solutions on SQLite CVSTrack. It depends in what direction you need to migrate: Sqlite -> Mysql or Mysql -> Sqlite.

I find it interesting to migrate to Sqlite, because overall performance of data analysis is faster in SQLite from 2.5x to 20x (and some queries in MySQL still can't be performed likt nested selects with limit clause).

You may need to correct your table schema. Here we go:


* MySQL to SQLite3 (shell script)

A quick way to convert a MySQL DB to SQLite3 is the following shell script (it does not claim to be complete):

#!/bin/sh

mysqldump --compact --compatible=ansi --default-character-set=binary mydbname |
grep -v ' KEY "' |
grep -v ' UNIQUE KEY "' |
perl -e 'local $/;$_=<>;s/,\n\)/\n\)/gs;print "begin;\n";print;print "commit;\n"' |
perl -pe '
if (/^(INSERT.+?)\(/) {
$a=$1;
s/\\'\''/'\'\''/g;
s/\\n/\n/g;
s/\),\(/\);\n$a\(/g;
}
' |
sqlite3 output.db



Edited 1 time(s). Last edit at 05/28/2006 01:39AM by alexey petrovsky.

Options: ReplyQuote


Subject
Views
Written By
Posted
18412
February 06, 2006 12:12PM
SQLite Migration - Converter tools
153000
May 28, 2006 01:36AM
12980
June 03, 2009 07:58AM
10098
February 13, 2009 06:29PM


Sorry, you can't reply to this topic. It has been closed.

Content reproduced on this site is the property of the respective copyright holders. It is not reviewed in advance by Oracle and does not necessarily represent the opinion of Oracle or any other party.