Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

145
Views
How to intelligently merge Django databases?

I have a Django project with 5 different PostgreSQL databases. The project was preemptively separated in terms of model routing, but has proven quite problematic so now I'm trying to reverse it. Unfortunately, there's some overlap of empty, migrated tables so pg_dump's out of the question. It looks like django-dumpdb may suit my needs but it doesn't handle per-database export/import. Additionally, Django's dumpdata/loaddata are installing 0 of the records from generated fixtures. Can I have some suggestions as to the least painful way to merge the data?

about 4 years ago · Santiago Trujillo
2 answers
Answer question

0

I had a similar issue, two identical websites sharing several models but with different objects. Unfortunately, merging them by natural_key was impossible.

I had to implement a new django commands similar to loaddata, in order to append all models from the second website into the first one.

You can find the code of the solution in this gist:

https://gist.github.com/MattFanto/f6c0ee0bc392da1d0d90f28efdb77e40

about 4 years ago · Santiago Trujillo Report

0

there's always the dump data from django, which is pretty easy to use.

or you could do this manually:

  • if the 2 databases share the same data (they are mirror one to another) and the same table structure, you could just run a syncdb from django to create the new table structure and then dump and import (i'm assuming you're using mysql, but the general idea is the same) the old database into the new one
  • if the two databases share different data (still with the same structure) you should import every single row of the two databases: this way, you'll keep relations etc, but you'll have your unique id updated to the new sole db.
  • if the two databases are different in both data and structure, you'll have to run two sincdb and two imports, but this doesn't seem to be your case
about 4 years ago · Santiago Trujillo Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!