Sqlite to Mysql Coversion

1) Use .schema output to construct valid mysql CREATE TABLE statements. It may be hard to guess your layout of SQLite because it’s typeless.

You can have such a schema –

CREATE TABLE yourtable (a,b,c,d,e);

– so it may be need to analyze structure of the each field and guess it’s type for all entries there. It maybe simplier if you have CREATE TABLE with types assigned.

Edit the header file in a separate file.

sqlite> .sch

– and copy&paste the table declaration into an editor of your preference.

2) Next step is create INSERT statements:

$ sqlite yourdatabase.db
sqlite> .mode insert
sqlite> .output yourdatabase2mysql.sql

OR:

$ echo “.dump” | sqlite yourdatabase.db > yourdatabase2mysql.sql

3) Insert your a) header file (see #1), b) yourdatabase2mysql.sql

$ mysql -u user -p password yourdatabase <your_header.sql
$ mysql -u user -p password yourdatabase <yourdatabas2mysql.sql

Hope this helps!

quoted from mysql forum

Advertisement

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Connecting to %s

Follow

Get every new post delivered to your Inbox.