Django : Transfer data from Sqlite to another database

14th February, 2019

Whenever a person starts learning Django, she/he starts from Sqlite database. And by the time you know most of the Django, you realize that that your most important data is in the Sqlite and now you would want to use high end databases like PostgreSQL or MySQL. 

In order to achieve that, do the following steps in order :

  1. python manage.py dumpdata > db.json
  2. Change the database settings to new database such as of MySQL / PostgreSQL.
  3. python manage.py migrate
  4. python manage.py shell 
    Enter the following in the shell
    from django.contrib.contenttypes.models import ContentType
    ContentType.objects.all().delete()
  5. python manage.py loaddata db.json


Thats it .. and now your new database should have all the data from the Sqlite. Cheers !