What's the best way to migrate a Django DB from SQLite to MySQL?

后端 未结 4 1297
你的背包
你的背包 2020-11-28 19:33

I need to migrate my db from sqlite to mysql, and the various tools/scripts out there are too many for me to easily spot the safest and most elegant solution.

This s

4条回答
  •  一个人的身影
    2020-11-28 20:15

    After some hard searching I got several problems that I hope future answer looking people will find useful.

    my formula is

    1. python manage.py dumpdata > datadump.json
    2. Change settings.py to your mysql
    3. Make sure you can connect on your mysql (permissions,etc)
    4. python manage.py migrate --run-syncdb
    5. Exclude contentype data with this snippet in shell

      python manage.py shell

      from django.contrib.contenttypes.models import ContentType ContentType.objects.all().delete() quit()

    6. python manage.py loaddata datadump.json

    Hope that will help you!

提交回复
热议问题