Skip to content

loulr/simple_dbt_project

 
 

Repository files navigation

This is the code repo for dbt tutorial at https://www.startdataengineering.com/post/dbt-data-build-tool-tutorial

Prerequisites

  1. Docker and Docker compose
  2. dbt
  3. pgcli
  4. git

Clone the git repo and start the data warehouse docker container

git clone https://github.com/josephmachado/simple_dbt_project.git
docker compose up -d

Run dbt

export DBT_PROFILES_DIR=$(pwd)
cd sde_dbt_tutorial
dbt snapshot
dbt run
dbt test
dbt docs generate
dbt docs serve

Insert updates into source customer table, to demonstrate snapshot

pgcli -h localhost -U dbt -p 5432 -d dbt
# password is password1234
COPY warehouse.customers(customer_id, zipcode, city, state_code, datetime_created, datetime_updated) FROM '/input_data/customer_new.csv' DELIMITER ',' CSV HEADER;
\q

Run snapshot and create models again.

dbt snapshot
dbt run

You can log into the data warehouse to see the models.

pgcli -h localhost -U dbt -p 5432 -d dbt
# password is password1234
select * from warehouse.customer_orders limit 3;
\q

Stop docker container

cd ..
docker compose down