dbt Set Up - iff133/first GitHub Wiki
1. Instal dbt:
command: pip install dbt
2. Create a dbt project:
command: dbt init [project_name]
This does three things:
- creates a ~/.dbt/profiles.yml file if one does not already exist
- creates a new folder called [project_name]
- generates directories and sample files necessary to get started with dbt (https://docs.getdbt.com/docs/init)
3. Change the profile.yml file:
-
Go to the file's location, which is in the **HOME DIRECTORY: ~** -> command:
cd ~
-
cd the ./dbt file -> command:
cd ./dbt
-
Edit the file in the command line -> command:
nano profiles.yml
-
Before:
-
After:
https://docs.getdbt.com/docs/supported-databases/profile-postgres/
3.1 To save the changes:
- Ctrl + O (save changes)
- Enter (accept changes)
- Ctrl + X (to exit) (https://help.ubuntu.com/community/Nano)
4. Create Models:
- Each model is equivalent to a job and uses SQL (select statements)
- Create a .sql file for every job that you want to run
- The
{{ config(materialized='table') }}
can be used so that the output is a new table in the database - The name for the table will be the same as the name of the .sql file
- The
ref
function can be used to select data from other models
5. Run the models:
commnad: dbt run
6. Access project's documentation:
- commnad:
dbt docs generate
- commnad:
dbt docs serve
- navigate to: http://localhost:8080
https://docs.getdbt.com/docs/documentation-website
Useful Links
https://blog.getdbt.com/what--exactly--is-dbt-/ https://docs.getdbt.com/ https://gitlab.demarq.com/demarq/dbt_mi/tree/master https://apple.stackexchange.com/questions/52461/how-to-save-and-exit-nano-bash-profile-in-terminal