0

I'm switching my database engine and need to convert my data. I can access both databases in a python shell with .using('[database]'). Does django have any built-in backup&restore functions that I could use to fill my empty(but migrated) new database?

Renoc
  • 419
  • 4
  • 13

1 Answers1

1

You can use dumpdata to export and loaddata to import.

Here are some examples:

dumpdata everything

python manage.py dumpdata > all.json

dumpdata one app

python manage.py dumpdata blog > blog.json

dumpdata specific model of app

python manage.py dumpdata blog.articles > blog_articles.json

loaddata

python manage.py loaddata all.json

By changing the settings.py database connection after you've dumped your data you don't have to use using at all.

More on this in the Django Docs.

Thomas Schwärzl
  • 9,518
  • 6
  • 43
  • 69
  • thanks, I ran into a few problems importing but found those answers here: https://stackoverflow.com/questions/853796/problems-with-contenttypes-when-loading-a-fixture-in-django – Renoc Oct 13 '17 at 20:34