[Fixed]-Django's "dumpdata" or Postgres' "pg_dump"?

13👍

It is both best practice and wiser for you to use pg_dump instead of dumpdata.

There are many reasons for this.

  • pg_dump is faster and the output is more compact (particularly with the -Fc option) than with dumpdata.

  • Importing the data back into the db with pg_restore will also be faster than django’s loaddata.

  • pg_restore is available on any postgresql installation but django and it’s dependencies you will have to install.

  • Last but not least the integrity errors that you spoke of will not happen with pg_dump/pg_restore.

Generally pg_dump is used to dump the entire database however the -t option allows you to dump one or few tables at a time

👤e4c5

Leave a comment