Skip to Content
AnalyticsdbtGetting Started

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.11python --version should report 3.11.x
  • Docker + Docker Compose — required to spin up a local Postgres instance
  • pipenvpip install pipenv if not present
  • Access to the PostgreSQL cluster credentials for the nhic_dbt profile (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_dbt

Install Python dependencies

The project uses a Pipfile that pins dbt-core and dbt-postgres:

pipenv install pipenv shell

Configure 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: 4

For 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 -d

This 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 deps

Test the connection

Verify dbt can reach the database and that your profile is correctly configured:

dbt debug

All 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 reporting

Test 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
Last updated on