Skip to content

Blocks Catalog

Below is a list of Blocks available for registration in prefect-dbt.

To register blocks in this module to view and edit them on Prefect Cloud, first install the required packages, then

prefect block register -m prefect_dbt
Note, to use the load method on Blocks, you must already have a block document saved through code or saved through the UI.

Cloud.Credentials Module

DbtCloudCredentials

Credentials block for credential use across dbt Cloud tasks and flows.

To load the DbtCloudCredentials:

from prefect import flow
from prefect_dbt.cloud.credentials import DbtCloudCredentials

@flow
def my_flow():
    my_block = DbtCloudCredentials.load("MY_BLOCK_NAME")

my_flow()
For additional examples, check out the Cloud.Credentials Module under Examples Catalog.

Cloud.Jobs Module

DbtCloudJob

Block that holds the information and methods to interact with a dbt Cloud job.

To load the DbtCloudJob:

from prefect import flow
from prefect_dbt.cloud.jobs import DbtCloudJob

@flow
def my_flow():
    my_block = DbtCloudJob.load("MY_BLOCK_NAME")

my_flow()
For additional examples, check out the Cloud.Jobs Module under Examples Catalog.

Cli.Configs.Base Module

TargetConfigs

Target configs contain credentials and settings, specific to the warehouse you're connecting to. To find valid keys, head to the Available adapters page and click the desired adapter's "Profile Setup" hyperlink.

To load the TargetConfigs:

from prefect import flow
from prefect_dbt.cli.configs.base import TargetConfigs

@flow
def my_flow():
    my_block = TargetConfigs.load("MY_BLOCK_NAME")

my_flow()
GlobalConfigs

Global configs control things like the visual output of logs, the manner in which dbt parses your project, and what to do when dbt finds a version mismatch or a failing model. Docs can be found here.

To load the GlobalConfigs:

from prefect import flow
from prefect_dbt.cli.configs.base import GlobalConfigs

@flow
def my_flow():
    my_block = GlobalConfigs.load("MY_BLOCK_NAME")

my_flow()
For additional examples, check out the Cli.Configs.Base Module under Examples Catalog.

Cli.Configs.Snowflake Module

SnowflakeTargetConfigs

Target configs contain credentials and settings, specific to Snowflake. To find valid keys, head to the Snowflake Profile page.

To load the SnowflakeTargetConfigs:

from prefect import flow
from prefect_dbt.cli.configs.snowflake import SnowflakeTargetConfigs

@flow
def my_flow():
    my_block = SnowflakeTargetConfigs.load("MY_BLOCK_NAME")

my_flow()
For additional examples, check out the Cli.Configs.Snowflake Module under Examples Catalog.

Cli.Configs.Bigquery Module

BigQueryTargetConfigs

dbt CLI target configs containing credentials and settings, specific to BigQuery.

To load the BigQueryTargetConfigs:

from prefect import flow
from prefect_dbt.cli.configs.bigquery import BigQueryTargetConfigs

@flow
def my_flow():
    my_block = BigQueryTargetConfigs.load("MY_BLOCK_NAME")

my_flow()
For additional examples, check out the Cli.Configs.Bigquery Module under Examples Catalog.

Cli.Configs.Postgres Module

PostgresTargetConfigs

dbt CLI target configs containing credentials and settings specific to Postgres.

To load the PostgresTargetConfigs:

from prefect import flow
from prefect_dbt.cli.configs.postgres import PostgresTargetConfigs

@flow
def my_flow():
    my_block = PostgresTargetConfigs.load("MY_BLOCK_NAME")

my_flow()
For additional examples, check out the Cli.Configs.Postgres Module under Examples Catalog.

Cli.Credentials Module

DbtCliProfile

Profile for use across dbt CLI tasks and flows.

To load the DbtCliProfile:

from prefect import flow
from prefect_dbt.cli.credentials import DbtCliProfile

@flow
def my_flow():
    my_block = DbtCliProfile.load("MY_BLOCK_NAME")

my_flow()
For additional examples, check out the Cli.Credentials Module under Examples Catalog.

Cli.Commands Module

DbtCoreOperation

A block representing a dbt operation, containing multiple dbt and shell commands.

For long-lasting operations, use the trigger method and utilize the block as a context manager for automatic closure of processes when context is exited. If not, manually call the close method to close processes.

For short-lasting operations, use the run method. Context is automatically managed with this method.

To load the DbtCoreOperation:

from prefect import flow
from prefect_dbt.cli.commands import DbtCoreOperation

@flow
def my_flow():
    my_block = DbtCoreOperation.load("MY_BLOCK_NAME")

my_flow()
For additional examples, check out the Cli.Commands Module under Examples Catalog.