Posted By

jmiller on 04/29/11


Tagged

import export SQLite mysqldump transfer


Versions (?)

MySQL to SQLite


 / Published in: Bash
 

URL: http://forums.mysql.com/read.php?145,68269,92627

Dump a MySQL database to SQLite

  1. mysqldump --compact --compatible=ansi --default-character-set=binary mydbname |
  2. grep -v ' KEY "' |
  3. grep -v ' UNIQUE KEY "' |
  4. perl -e 'local $/;$_=<>;s/,\n\)/\n\)/gs;print "begin;\n";print;print "commit;\n"' |
  5. perl -pe '
  6. if (/^(INSERT.+?)\(/) {
  7. $a=$1;
  8. s/\\'\''/'\'\''/g;
  9. s/\\n/\n/g;
  10. s/\),\(/\);\n$a\(/g;
  11. }
  12. ' |
  13. sqlite3 sqlite.db

Report this snippet  

You need to login to post a comment.