是否可以使用 pg-promise 在同一个查询中使用多个数据库?
Is it possible to use multiple databases within same query using pg-promise?
我在不同的数据库 D1 和 D2 中有两个相关的表 T1 和 T2。我需要在两个表之间进行内部连接。
从这里开始:Joining Results from Two Separate Databases it is clear that separate queries should be made to two databases and results to be consolidated on client side OR use dblink / postgres-fdw.
但是,我看到了这个问题:多个数据库 #1
和此处使用 $dc
参数:pg-promise/Database.
我认为问题:多个数据库 #1
只是方便允许在同一代码库中连接到多个数据库。
$dc
参数说明:
This is mainly to facilitate the use of multiple databases which may need separate protocol extensions, or different implementations within a single task
但是,我没有找到任何示例。
$dc
参数只是一个可以访问的数据库上下文对象,还是允许在两个不同的数据库之间进行内部连接?
有没有一种方法可以利用两个数据库连接,而不必在客户端使用 pg-promise
进行跨数据库连接?
Is the $dc paramter just a database context object that can be accessed, or would it allow to do an inner join between two different databases?
是前者。
Is there a way to do utilise two database connections but do a join across databases in without having to do it on client-side using pg-promise?
没有。每个 Database 对象只代表一个到数据库的连接。
我在不同的数据库 D1 和 D2 中有两个相关的表 T1 和 T2。我需要在两个表之间进行内部连接。
从这里开始:Joining Results from Two Separate Databases it is clear that separate queries should be made to two databases and results to be consolidated on client side OR use dblink / postgres-fdw.
但是,我看到了这个问题:多个数据库 #1
和此处使用 $dc
参数:pg-promise/Database.
我认为问题:多个数据库 #1 只是方便允许在同一代码库中连接到多个数据库。
$dc
参数说明:
This is mainly to facilitate the use of multiple databases which may need separate protocol extensions, or different implementations within a single task
但是,我没有找到任何示例。
$dc
参数只是一个可以访问的数据库上下文对象,还是允许在两个不同的数据库之间进行内部连接?
有没有一种方法可以利用两个数据库连接,而不必在客户端使用 pg-promise
进行跨数据库连接?
Is the $dc paramter just a database context object that can be accessed, or would it allow to do an inner join between two different databases?
是前者。
Is there a way to do utilise two database connections but do a join across databases in without having to do it on client-side using pg-promise?
没有。每个 Database 对象只代表一个到数据库的连接。