1

How to transfer data in django from sqlite to mysql, so that all the data that is in the admin are preserved?

I have a database with the same tables, where I can transfer all the data. I tried to do it the standard way throughpython manage.py loaddata datadump.json. The data in the tables was transferred but the admin panel got stuck. I use wagtail django admin.

To be more clear, I need information and not the structure itself

  • Possible duplicate of [Quick easy way to migrate SQLite3 to MySQL?](https://stackoverflow.com/questions/18671/quick-easy-way-to-migrate-sqlite3-to-mysql) – Danil Aug 21 '18 at 18:04

1 Answers1

0
    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

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

    7) python manage.py loaddata datadump.json
Abhiram
  • 1,540
  • 1
  • 11
  • 25
  • I did not understand a bit how to remove? – Міша Жуковський Aug 24 '18 at 10:44
  • i have error _mysql_exceptions.IntegrityError: (1451, 'Cannot delete or update a parent row: a foreign key constraint fails (`kristall_database`.`wagtailcore_page`, CONSTRAINT `wagtailcore_page_content_type_id_c28424df_fk_dja ngo_co` FOREIGN KEY (`content_type_id`) REFERENCES `django_content_type` (`id`))') – Міша Жуковський Aug 24 '18 at 10:51
  • You will get `CommandError: No installed app with label '>'.` if you run `python manage.py dumpdata > datadump.json` – Nairum Jul 28 '19 at 10:38