Getting Started with dbt
This guide walks through setting up a local nhic_dbt development environment from scratch.
Production dbt runs are triggered by Prefect workflows — not run directly from CI or your laptop. Local runs are for development and testing only.
Prerequisites
Make sure the following are installed before continuing:
- Python 3.11 —
python --versionshould report3.11.x - Docker + Docker Compose — required to spin up a local Postgres instance
- pipenv —
pip install pipenvif not present - Access to the PostgreSQL cluster credentials for the
nhic_dbtprofile (see your team lead)
Clone and navigate to the project
git clone git@github.com:Sand-EnterpriseAI/Healthcare.MOH.RWA.HIC.git
cd Healthcare.MOH.RWA.HIC/apps/analytics/nhic_dbtInstall Python dependencies
The project uses a Pipfile that pins dbt-core and dbt-postgres:
pipenv install
pipenv shellConfigure the dbt profile
dbt reads connection details from profiles.yml. Create or update the file at the project root (it is git-ignored):
nhic_dbt:
target: dev
outputs:
dev:
type: postgres
host: localhost
port: 5432
dbname: nhic
user: nhic
password: nhic
schema: public
threads: 4For connecting to a non-local environment, update host, port, dbname, user, and password to match the target cluster.
Start the local database
Docker Compose brings up a Postgres container pre-configured for local development:
docker-compose up -dThis starts Postgres on localhost:5432. The default credentials match the dev profile above.
Install dbt packages
Pull in any dbt package dependencies declared in packages.yml:
dbt depsTest the connection
Verify dbt can reach the database and that your profile is correctly configured:
dbt debugAll checks should pass. If the connection fails, double-check profiles.yml and confirm the Docker container is running.
Run the models
Run the full project or target a single layer:
# Full run — all four layers
dbt run
# Run a single layer
dbt run --select staging
dbt run --select intermediate
dbt run --select dwh
dbt run --select reportingTest the models
Run all schema and custom tests:
# All tests
dbt test
# Tests for a specific layer
dbt test --select staging
dbt test --select tag:dwh