Sample Simple DBT Project

Requirements

  • python 3+

  • psycopg2

  • dbt == 0.12.2

  • postgresql (any recent version, locally installed)

Set up:

copy the file profile.yml.sample to ~/.dbt/profile.yml, or add its contents to your existing profile.yml file.

Create a database user & database according to the credentials in profile.yml.sample, or use your own, but remember update profile.yml with your own credentials.

Create a users table & populate with sample data

CREATE TABLE orders (
  order_id int primary key generated by default as identity
, user_id int not null
, revenue numeric(10, 4) not null
, created_at timestamp with time zone default current_timestamp
, updated_at timestamp with time zone default current_timestamp
);
INSERT INTO orders (user_id, revenue) 
VALUES
  (1, 100)
, (1, 100)
, (1, 200)
, (2, 100)
, (2, 500);

Run & Test

from the command prompt

> dbt run
> dbt test