Docs
https://prefecthq.github.io/prefect-dbt/
Code
Examples
Trigger a dbt Cloud job and wait for completion
from prefect import flow
from prefect_dbt.cloud import DbtCloudCredentials
from prefect_dbt.cloud.jobs import trigger_dbt_cloud_job_run_and_wait_for_completion
@flow
def trigger_dbt():
run_result = trigger_dbt_cloud_job_run_and_wait_for_completion(
dbt_cloud_credentials=DbtCloudCredentials(
api_key="my_api_key",
account_id=123456789
),
job_id=1
)
trigger_dbt()
Execute a dbt CLI command
from prefect import flow
from prefect_dbt.cli.commands import trigger_dbt_cli_command
@flow
def trigger_dbt() -> str:
result = trigger_dbt_cli_command("dbt debug")
return result # Returns last line of CLI output
trigger_dbt()