Renoc
Renoc

Reputation: 439

Convert Full Database to Different database Format using django

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?

Upvotes: 0

Views: 216

Answers (1)

Thomas Schwärzl
Thomas Schwärzl

Reputation: 9917

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.

Upvotes: 1

Related Questions