Migrating from SQLite to MySQL

7 views
Skip to first unread message

matt...@gmail.com

unread,
Feb 25, 2013, 11:02:37 PM2/25/13
to py...@googlegroups.com
I accidentally let an app slip into production using SQLite and need to switch it over to PostgreSQL or MySQL (MySQL slightly preferred).

My first thought was to do:

./manage.py dumpdata > ~/export.json

However that fails after about 20 seconds and simply says: "Killed"

Here is a copy and paste:

$ ./manage.py dumpdata > ~/.export.json
Killed

If I use -v 2 to increase the verbosity or I use --traceback nothing is changed. In all cases export.json is empty.

I'm not doing anything particularly clever with the models. The SQLite file is about 250MB in size. Anyone have any ideas on what could be done to migrate this? 

--
Matthew Nuzum
newz2000 on freenode, skype, linkedin and twitter

 You're never fully dressed without a smile! 

Matthew J. Morrison

unread,
Feb 25, 2013, 11:51:20 PM2/25/13
to py...@googlegroups.com

Is your Django project broken apart into separate apps? Could you maybe try to dump one app at a time and if that doesn't work do one model at a time? (https://docs.djangoproject.com/en/dev/ref/django-admin/#dumpdata-appname-appname-appname-model)

Just googling around, I found this post on stack overflow. It sounds like you should be able to generate a database dump from sqlite using "sqlite3 database .dump" then pipe that into postgres, or probably even mysql. This might be your best option. What I would try is to go ahead and use Django to create your schema then use mysql to dump only the insert commands (not the schema since the types and syntax are probably slightly different). You can do this using "sqlite3 database .dump | grep INSERT > dump.sql" or something along those lines. You may still need to do some find/replace on the database dump if there are any syntax differences between the sqlite insert and the mysql or postgres inserts. 

If that doesn't work, typically I just end up writing a script that reads from one database and writes to another. That is probably just a last resort, but it would work. 

Hope that helps!

Good luck!
-Matt


--
You received this message because you are subscribed to the Google Groups "Pyowa" group.
To unsubscribe from this group and stop receiving emails from it, send an email to pyowa+un...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.
 
 



--
Matthew J. Morrison

Reply all
Reply to author
Forward
0 new messages