MySQL to SQLite


/ Published in: Bash
Save to your folder(s)

Dump a MySQL database to SQLite


Copy this code and paste it in your HTML
  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

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

Report this snippet


Comments

RSS Icon Subscribe to comments

You need to login to post a comment.