Django: convert an application from sqlite to mysql

Posted by jason on July 11, 2011, 6 a.m.
Tags: django mysql python sqlite

Thanks to Steve Lord for this one.

Here's how to take a local django application in sqlite and deploy it into a mysql production environment.

First, use django's script to dump the data to a json file.

cd <django-project-dir>
python2 dumpdata <appname> > <appname>.json

After this step is done, copy the .json file to your production server.

Next, create your mysql user, database, etc. in production, and then update the file to use the proper mysql variables.

Finally, import the .json file with django's script.

python2 loaddata <appname>.json