Implementation:Astronomer Astronomer cosmos DuckDBUserPasswordProfileMapping
| Knowledge Sources | |
|---|---|
| Domains | Profile_Mapping, DuckDB |
| Last Updated | 2026-02-07 17:00 GMT |
Overview
Concrete tool for mapping Airflow duckdb connections to dbt duckdb profiles provided by astronomer-cosmos.
Description
The DuckDBUserPasswordProfileMapping maps an Airflow duckdb connection to a dbt duckdb profile. It translates connection parameters into the YAML structure that dbt expects in `profiles.yml`. This is a community-contributed adapter (`is_community=True`). DuckDB profiles are minimal, primarily requiring a path to the database file which is extracted from the Airflow connection host or extras.
Usage
Use this profile mapping when configuring Cosmos to run dbt commands against a DuckDB backend. Assign it to `ProfileConfig(profile_mapping=...)` when the target Airflow connection uses the `duckdb` connection type.
Code Reference
Source Location
- Repository: Astronomer_Astronomer_cosmos
- File: cosmos/profiles/duckdb/user_pass.py
Signature
class DuckDBUserPasswordProfileMapping(BaseProfileMapping):
airflow_connection_type: str = "duckdb"
dbt_profile_type: str = "duckdb"
is_community: bool = True
Import
from cosmos.profiles.duckdb import DuckDBUserPasswordProfileMapping
I/O Contract
Inputs
| Name | Type | Required | Description |
|---|---|---|---|
| conn_id | str | Yes | Airflow connection ID for DuckDB |
Outputs
| Name | Type | Description |
|---|---|---|
| profile | dict | dbt profile YAML dictionary |
| env_vars | dict | Environment variables for secret fields |
Usage Examples
from cosmos.config import ProfileConfig
from cosmos.profiles.duckdb import DuckDBUserPasswordProfileMapping
profile_config = ProfileConfig(
profile_name="default",
target_name="dev",
profile_mapping=DuckDBUserPasswordProfileMapping(conn_id="duckdb_default"),
)