Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

MySQL -- Joins Between Databases On Different Servers Using Python?

Tags:

python

mysql

In MySQL, I have two different databases -- let's call them A and B.

Database A resides on server server1, while database B resides on server server2.

Both servers {A, B} are physically close to each other, but are on different machines and have different connection parameters (different username, different password etc).

In such a case, is it possible to perform a join between a table that is in database A, to a table that is in database B?

If so, how do I go about it, programatically, in python? (I am using python's MySQLDB to separately interact with each one of the databases).

like image 942
user3262424 Avatar asked Apr 29 '11 13:04

user3262424


People also ask

Can we join two tables from different databases in SQL Server?

SQL Server allows you to join tables from different databases as long as those databases are on the same server. The join syntax is the same; the only difference is that you must fully qualify table names.

Can you join across databases MySQL?

Yes, assuming the account has appropriate permissions you can use: SELECT <...> FROM A. table1 t1 JOIN B.


1 Answers

Try to use FEDERATED Storage Engine.

Workaround: it is possible to use another DBMS to retrieve data between two databases, for example you could do it using linked servers in MS SQL Server (see sp_addlinkedserver stored procedure). From the documentation:

A linked server allows for access to distributed, heterogeneous queries against OLE DB data sources.

like image 87
Devart Avatar answered Oct 08 '22 23:10

Devart