Merge two Databases into one

107 views
Skip to first unread message

Ram Ganesh

unread,
Oct 24, 2014, 1:17:12 PM10/24/14
to django...@googlegroups.com
Hi all,

I want to append my datas from old_db to new_db
they have exactly the same structure,

I'm trying to Write a Script using Django Manually selecting a database
  -Read data from old_db and Write it into new_db
  -But not sure its work fine with maintaining foreign key relationships.

what do you think would be the best solution for my problem?

using MySql,
Django 1.3

Thanks,
Ram Ganesh K

Larry Martell

unread,
Oct 24, 2014, 1:25:05 PM10/24/14
to django...@googlegroups.com
If this is just a one time thing, I'd just write a python script. Or
you could dump the old_db using --no-create-info and then load it to
the new db from the command line.

Majo

unread,
Oct 25, 2014, 10:27:01 AM10/25/14
to django...@googlegroups.com
Larry's right, if it's a one time thing, use

mysqldump -u YOUR_DB_USER -p OLD_DB --no-create-info > SOME_FILE.sql

from the command line. Then, to import, use:
mysqlimport -u YOUR_DB_USER -p NEW_DB SOME_FILE.sql

To be sure you understand what's happening, check the docs first:

http://dev.mysql.com/doc/refman/5.0/en/mysqldump.html
and
http://dev.mysql.com/doc/refman/5.0/en/mysqlimport.html

Also, don't forget to create a backup of your new_db (by using mysqldump as described above, just without the --no-create-info)


Unrelated to your question, but you might also want to consider to upgrade your Django installation to something newer than 1.3 ;)
Reply all
Reply to author
Forward
0 new messages