Skip to content

[Experiment] Build context from dbt's backing DB (using DBT credentials)#178

Draft
JulienArzul wants to merge 3 commits intomainfrom
experiment-read-credentials-from-dbt
Draft

[Experiment] Build context from dbt's backing DB (using DBT credentials)#178
JulienArzul wants to merge 3 commits intomainfrom
experiment-read-credentials-from-dbt

Conversation

@JulienArzul
Copy link
Copy Markdown
Collaborator

@hsestupin I've written a script as an experiment that takes a DBT project as input and:

  1. Extract credentials from the DBT project (by using APIs from dbt-core)
  2. Map those credentials to the right Config type
  3. Build the context for that type

@JulienArzul JulienArzul requested a review from hsestupin April 10, 2026 08:05
@JulienArzul
Copy link
Copy Markdown
Collaborator Author

Apparently, the DBT core library is not compatible with Python 3.14.. (see tests failing and this related issue)

Comment thread pyproject.toml

[tool.uv]
override-dependencies = ["urllib3>=2.6.3", "filelock>=3.20.3", "virtualenv>=20.36.1"]
override-dependencies = ["urllib3>=2.6.3", "filelock>=3.20.3", "virtualenv>=20.36.1", "dbt-adapters~=1.22"]
Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The various dbt-adapters implementations (dbt-postgres and dbt-sqlite specifically) don't play well together... So I had to pin the dbt-adapters to a specific version => the version I pinned is higher than the one requested by postgres and sqlite but corresponds to the one used by snowflake.
I have tested both postgres and sqlite, and nothing fails at runtime for the use we're making (and hopefully nothing should be broken since the pinned version is only a couple minor version upgrade, that should in theory not have breaking changes)

(project_path / "models").mkdir()
(project_path / "models" / "example.sql").write_text("select 1 as id\n", encoding="utf-8")
(project_path / "dbt_project.yml").write_text(
"\n".join(
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That's weird way to create multiline string, when python has triple quotes for that?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants