MySQL-使用Python在不同服务器上的数据库之间联接吗? [英] MySQL -- Joins Between Databases On Different Servers Using Python?

查看:107
本文介绍了MySQL-使用Python在不同服务器上的数据库之间联接吗?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

MySQL中,我有两个不同的数据库-我们称它们为AB.

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.

两个服务器{AB}在物理上彼此接近,但是它们位于不同的计算机上,并且具有不同的连接参数(不同的用户名,不同的密码等).

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中以编程方式进行处理? (我正在使用pythonMySQLDB分别与每个数据库进行交互).

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屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆