Skip to content

Latest commit

 

History

History
86 lines (53 loc) · 1.48 KB

File metadata and controls

86 lines (53 loc) · 1.48 KB

dbt-postgres

This repo contains a docker file to run PostgreSQL and PGAdmin using docker compose. It also contains some raw data from a fictional app and some indications to get started with dbt.

PostgreSQL - PGAdmin

Change to the right directory and run:

docker compose up

dbt steps

  1. Create a new virtual environment in your project and activate it.
python3 -m venv .venv

source .venv/bin/activate

Windows:

python -m venv .venv

.venv\Scripts\activate
  1. Then install dbt-core and the postgres adapter.

python3 -m pip install dbt-core dbt-postgres

  1. Create profiles.yml file to connect dbt to postgres.
mkdir ~/.dbt 

vi ~/.dbt/profiles.yml

(copy code)

Windows:

C:\Users\yourUser
Create folder: .dbt and add profiles.yml.

  1. dbt init to create a new dbt project.

dbt init jaffle_shop

"The profile jaffle_shop already exists in /Users/...../profiles.yml. Continue and overwrite it? [y/N]:" --> n

  1. Delete the folder: jaffle_shop/models/example

  2. In dbt_project.yml, delete lines 35 and 36.

  3. Check connection

cd jaffle shop

dbt run
  1. Add csv files in seeds folder.

  2. Run seed to upload files to postgres

dbt seed

  1. Verify the data is available in pgAdmin and delete CSV files from seeds folder.

  2. Start modeling.

Commands

dbt seed
dbt run
dbt test
dbt test --select test_type:generic
dbt test --select test_type:singular
dbt test --select one_specific_model
dbt docs generate
dbt docs serve