merging 2 mysql databases with java

jazzIIIlove
jazzIIIlove used Ask the Experts™
on
Hi,

I need to merge 2 mysql databases with java or python.

The databases are exactly the same in schema but data is different.

in terms of the query which i need to pass in java or python. Anything i should care about?

Would it be the case that i need to insert data to the table having foreign key first?

what is the strategy?

Br.
Comment
Watch Question

Do more with

Expert Office
EXPERT OFFICE® is a registered trademark of EXPERTS EXCHANGE®
Top Expert 2016

Commented:
I don't think there's a 'simple' way to do it. It's just a question of putting the work in
Hi,

But any approach you suggest?

Br.
Top Expert 2016

Commented:
You need to issue a series of queries for each and every table
Amazon Web Services

Are you thinking about creating an Amazon Web Services account for your business? Not sure where to start? In this course you’ll get an overview of the history of AWS and take a tour of their user interface.

Should i do this e.g
A) Table 2 fk (source): insert into Table 2' fk (target)

B) Table 1 pk (source): insert into Table 1' pk (target)

Should i do in this order (A, B)

Fk: foreign key, Pk: primary key

Prime tables are the tables that will have the merged data
Top Expert 2016

Commented:
Foreign keys would be a consideration if you are going to get referential integrity violations, yes. In that case, you need to do them in an order that doesn't cause violations
Do you think my above order is correct?
Top Expert 2016
Commented:
I'm not sure if i understand your notation but the general principle is that the table with a foreign key must be done after the table to which it refers (i.e. the one that contains that key)

Do more with

Expert Office
Submit tech questions to Ask the Experts™ at any time to receive solutions, advice, and new ideas from leading industry professionals.

Start 7-Day Free Trial