Prefect-dbt is an official Prefect integration for orchestrating dbt (data build tool) projects within Prefect workflows. It provides tasks and blocks for interacting with the dbt CLI, allowing users to run dbt commands (like `dbt run`, `dbt test`, `dbt build`) as part of their data pipelines. The current version is 0.7.20, and it follows Prefect's release cadence for integrations, with updates typically coinciding with or following major Prefect releases.
pip install prefect-dbtVerified import paths — ran on the pinned version, not inferred.
This quickstart demonstrates a simple Prefect flow that uses `prefect-dbt` to execute the `dbt debug` command. This is a good starting point as it verifies the dbt installation and profile configuration without requiring a full dbt project or database connection. For `dbt run`, `dbt test`, etc., you would typically set up a `DbtCliProfile` block in the Prefect UI and load it in your flow.
Migrate from `from prefect_dbt.cli import dbt_cli_task` to `from prefect_dbt.cli import DbtCli` and instantiate the class to call dbt commands (e.g., `DbtCli().run()`).
Ensure `dbt-core` and your chosen dbt adapter are installed in your flow's execution environment using `pip install dbt-core [your-adapter]`.
Create a `DbtCliProfile` block in the Prefect UI with your dbt profile configuration. Then, load and pass this block to `DbtCli` (e.g., `DbtCli(dbt_profile=DbtCliProfile.load('my-profile'))`).Consult the `prefect-dbt` documentation for supported `dbt-core` versions. Test your flows thoroughly after upgrading either `prefect-dbt` or `dbt-core`.