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 manage.py script to dump the data to a json file.

cd <django-project-dir>
python2 manage.py 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 settings.py file to use the proper mysql variables.

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

python2 manage.py loaddata <appname>.json

0 comments