Ouch! I developed on sqlite3. I need to switch from sqlite to mysql database now
Wrote at December 07, 2009 da Filippo Camillo
I'm currently working on a Ruby on Rails project with a team of 3 people. We used sqlite3 as database system because it's easly portable and versionable (only 1 file).
But now, we need to port the contents from sqlite to mysql and import in the production server.
I wrote a easy step by step tutorial to convert data from sqlite to mysql, so start your engine!
1 Export the sqlite database
To do that you have to open you terminal
cd appdirecotry sqlite3 db/development.sqlite3 dump .quit => dbexported.sql
2 Edit the sql file
Now we have to edit this .sql file because sqlite3 exports some things and characters that we don't want.
Remove all the "BEGIN TRANSACTION;"
Remove all the "COMMIT;"
Remove entire lines related to "sqlite_sequence"
Replace double quotes (") with grave accent (`)
Change "autoincrement" in "auto_increment"
3 Save and import
The sql file is finally ready and you can safely import it into the production server
1 comment
-
On December 07, 2009, Davide wrote:I had a similar problem, and I solved it with the yaml_db plugin, which allows to convert from db to yaml and back to db; it's by the heroku guys: http://github.com/adamwiggins/yaml_db So I saved my local stuff to yaml, deployed and loaded the stuff into the db via ssh. I guess one could also make a cap task.