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.
Change to the right directory and run:
docker compose up
- 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
- Then install dbt-core and the postgres adapter.
python3 -m pip install dbt-core dbt-postgres
- 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.
- 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
-
Delete the folder: jaffle_shop/models/example
-
In dbt_project.yml, delete lines 35 and 36.
-
Check connection
cd jaffle shop
dbt run
-
Add csv files in seeds folder.
-
Run seed to upload files to postgres
dbt seed
-
Verify the data is available in pgAdmin and delete CSV files from seeds folder.
-
Start modeling.
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