script to convert mysql dump sql file into format that can be imported into sqlite3 db

后端 未结 9 2217
说谎
说谎 2020-11-29 03:07

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

9条回答
  •  难免孤独
    2020-11-29 03:50

    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.

提交回复
热议问题