Skip to content

Commit ff836db

Browse files
[dagster-dbt] Add profiles_dir, profile and target to dbt reference (#29145)
## Summary & Motivation As title. ## How I Tested These Changes Docs preview
1 parent dfe859d commit ff836db

File tree

2 files changed

+29
-0
lines changed
  • docs/docs/integrations/libraries/dbt
  • examples/docs_snippets/docs_snippets/integrations/dbt

2 files changed

+29
-0
lines changed

docs/docs/integrations/libraries/dbt/reference.md

+12
Original file line numberDiff line numberDiff line change
@@ -105,6 +105,18 @@ dagster dev
105105

106106
In production, a precompiled manifest should be used. Using <PyObject section="libraries" object="DbtProject" module="dagster_dbt" />, the manifest can be created at build time by running the [`dagster-dbt project prepare-and-package`](/api/python-api/libraries/dagster-dbt#prepare-and-package) command in your CI/CD workflow. For more information, see the [Deploying a Dagster project with a dbt project](#deploying-a-dagster-project-with-a-dbt-project) section.
107107

108+
## Selecting a profiles directory, profile and target for your dbt project
109+
110+
You can specify which connection information dbt should use when parsing and executing your models. This can be done by passing the profiles directory, profile and target to your when creating your <PyObject section="libraries" object="DbtProject" module="dagster_dbt" /> object. These fields are optional - the default values defined in your dbt project will be used for each parameter that is not passed.
111+
112+
<CodeExample
113+
path="docs_snippets/docs_snippets/integrations/dbt/dbt.py"
114+
startAfter="start_connection_information_with_dbt_project"
115+
endBefore="end_connection_information_with_dbt_project"
116+
/>
117+
118+
For more information, see dbt's guide about [connection profiles](https://docs.getdbt.com/docs/core/connect-data-platform/connection-profiles).
119+
108120
## Deploying a Dagster project with a dbt project
109121

110122
:::note

examples/docs_snippets/docs_snippets/integrations/dbt/dbt.py

+17
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,23 @@ def scope_compile_dbt_manifest_with_dbt_project(manifest):
1919
# end_compile_dbt_manifest_with_dbt_project
2020

2121

22+
def scope_connection_information_with_dbt_project():
23+
# start_connection_information_with_dbt_project
24+
from pathlib import Path
25+
26+
from dagster_dbt import DbtProject
27+
28+
my_dbt_project = DbtProject(
29+
project_dir=Path(__file__).joinpath("..", "..", "..").resolve(),
30+
profiles_dir=Path(__file__)
31+
.joinpath("..", "..", "..", "my_profiles_dir")
32+
.resolve(),
33+
profile="my_profile",
34+
target="my_target",
35+
)
36+
# end_connection_information_with_dbt_project
37+
38+
2239
def scope_schedule_assets_dbt_only(manifest):
2340
from dagster import Config
2441

0 commit comments

Comments
 (0)