Skip to content

DBT Macro: Attach Postgres

DBT macro name: trase_duckdb.attach_postgres

DBT details


Description

No description


Details

Macros

  • run_query
{% macro attach_postgres() %}

-- Only do the following if within a dbt run (not whenever compiling)
{% if execute %}
    {% set dynamic_db_name = this.identifier ~ '_postgres_db' %}
    {% set attach_query = "ATTACH 'service=production_readonly dbname=trase' AS " ~ dynamic_db_name ~ " (TYPE POSTGRES, READ_ONLY); SET pg_experimental_filter_pushdown=true;" %}

    {% do run_query(attach_query) %}
    {{ log("Attached to " ~ dynamic_db_name ~ " in Read-only mode...", info=True) }}
{% endif %}
{% endmacro %}