DBT Labs使用DB链接访问远程Postgres DB服务器

发布于 2025-02-05 18:44:32 字数 153 浏览 1 评论 0原文

我是DBT的新手。我了解DBT一旦DWH中的原始数据可用,DBT用于转换数据。但是,我试图查看是否有人使用DBT在选择语句中使用db link从远程数据库服务器进行初始选择/导入数据,其中staging数据库服务器和远程数据库服务器都是Postgres数据库。 同样,就我而言,数据量并不多。

I am new to DBT. I understand that DBT is used for transforming data once the raw data is available in your DWH. However I was trying to see if anyone has used DBT to do an initial select/import of data into staging tables from a remote database server using DB link in a select statement where both the staging database server and the remote database server are Postgres databases.
Also in my case the data volume isn’t much.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

静若繁花 2025-02-12 18:44:32

我能够进行一些测试,看起来这是可行的。
以下是设置:

  1. profiles.yml文件指向目标数据库服务器。
  2. 以下是模型targetTable.sql文件中使用的查询。
{{ config(materialized='table') }}

SELECT i.col1,
        i.col2
        FROM dblink('dbname=sourceDBName port=portNo hostaddr=sourceHostName user=userID password=****', 
                                'SELECT 
                                a.col1, 
                                a.col2
                                from 
                                (SELECT 
                                    col1,col2
                                 FROM 
                                    public.tableName) a
                                ') 
                i (col1 integer, col2 varchar(20))

I was able to do some testing and looks like this is doable.
Below was the set-up:

  1. The profiles.yml file was pointing to target DB server.
  2. Below was the query used in the model targetTable.sql file.
{{ config(materialized='table') }}

SELECT i.col1,
        i.col2
        FROM dblink('dbname=sourceDBName port=portNo hostaddr=sourceHostName user=userID password=****', 
                                'SELECT 
                                a.col1, 
                                a.col2
                                from 
                                (SELECT 
                                    col1,col2
                                 FROM 
                                    public.tableName) a
                                ') 
                i (col1 integer, col2 varchar(20))
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文