MySQL-使用Python在不同服务器上的数据库之间联接吗? [英] MySQL -- Joins Between Databases On Different Servers Using Python?
问题描述
在MySQL
中,我有两个不同的数据库-我们称它们为A
和B
.
In MySQL
, I have two different databases -- let's call them A
and B
.
数据库A
驻留在服务器server1
上,而数据库B
驻留在服务器server2
上.
Database A
resides on server server1
, while database B
resides on server server2
.
两个服务器{A
,B
}在物理上彼此接近,但是它们位于不同的计算机上,并且具有不同的连接参数(不同的用户名,不同的密码等).
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).
在这种情况下,是否可以在数据库A
中的表与数据库B
中的表之间进行联接?
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
?
如果是这样,我该如何在python
中以编程方式进行处理? (我正在使用python
的MySQLDB
分别与每个数据库进行交互).
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).
推荐答案
尝试使用解决方法:可以使用另一个DBMS在两个数据库之间检索数据,例如,您可以使用MS SQL Server中的链接服务器进行处理(请参见
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:
链接服务器允许访问针对OLE DB数据源的分布式异构查询.
A linked server allows for access to distributed, heterogeneous queries against OLE DB data sources.
这篇关于MySQL-使用Python在不同服务器上的数据库之间联接吗?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!