DataKit Python SDK — store discovery and dbt profiles generation for DataKit.
# From GitHub release (latest)
pip install datakit-sdk@https://github.com/infobloxopen/datakit-sdk-python/releases/latest/download/datakit_sdk-0.1.0-py3-none-any.whl
# From source
pip install git+https://github.com/infobloxopen/datakit-sdk-python.git
# From local checkout
pip install -e .The dk dbt command in the DataKit CLI uses this package to:
- Read
DK_STORE_DSN_*/DK_STORE_TYPE_*environment variables (injected bydk runor the DataKit controller) - Generate a
profiles.ymlfor dbt with the correct connection details - dbt then uses that profile to connect to the database
# Generate profiles.yml from environment variables
export DK_STORE_DSN_WAREHOUSE="postgresql://user:pass@host:5432/db?schema=stage"
export DK_STORE_TYPE_WAREHOUSE="postgres"
dk-profiles generate # writes profiles.yml to current dir
dk-profiles generate -o /app # writes to /app/profiles.yml
dk-profiles generate --project my_project # override project namefrom datakit import stores
# Get a specific store
warehouse = stores.get("warehouse")
print(warehouse.dsn) # "postgresql://user:pass@host:5432/db"
print(warehouse.type) # "postgres"
# Discover all stores
for name, store in stores.all().items():
print(f"{name}: {store.type} -> {store.dsn}")from datakit.profiles import generate_profiles
# Generate dbt profiles YAML string
yaml_str = generate_profiles("my_project")The DataKit platform injects two env vars per store:
| Variable | Example | Description |
|---|---|---|
DK_STORE_DSN_<NAME> |
DK_STORE_DSN_WAREHOUSE=postgresql://... |
Connection string |
DK_STORE_TYPE_<NAME> |
DK_STORE_TYPE_WAREHOUSE=postgres |
Connector type |
<NAME> is the store name uppercased with hyphens replaced by underscores.
pip install -e ".[dev]"
pytestApache-2.0