- Download and install Python
- Download and install Git
- Download and install Nodejs
- Download and install VScode
- For windows: Download and install windows terminal
- Open a terminal
- Clone the repository:
git clone https://github.com/artefactory/dbt_intro_da.git
- Change directory in the repository folder:
cd dbt_intro_da
- Setup a python environment:
- MacOs:
python3 -m venv .venv
- Windows:
python -m venv .venv
- MacOs:
- Activate python environment:
- MacOs:
source .venv/bin/activate
- Windows:
Set-ExecutionPolicy -ExecutionPolicy Unrestricted -Scope CurrentUser
. .\.env\Scripts\activate
- MacOs:
- Install python packages
pip install -r requirements.txt
Additionnal setup to work with bigquery (optionnal)
In order to work with bigquery you need to change the target in the profiles to the bigquery target.
You also need to update the dataset used in the profile by changing name
to your name.
dbt_intro_da:
target: dev_bigquery
outputs:
duckdb:
path: dbt.duckdb
type: duckdb
threads: 4
dev_bigquery:
type: bigquery
method: oauth
project: formation-sql-316408
dataset: dbt_intro_da_name
location: EU
threads: 4
- Download and install Gcloud
- Connect to gcloud:
gcloud auth application-default login \
--scopes=https://www.googleapis.com/auth/bigquery,\
https://www.googleapis.com/auth/drive.readonly,\
https://www.googleapis.com/auth/iam.test
dbt debug
should now tell you everything is OKdbt deps
to install dbt packages used in this projectdbt run
The first dbt run
should create a file named dbt.duckdb
.
This file will contains all the tables views we are creating.
To observe and monitor the new tables and views we are creating with dbt we can use VScode and some extensions to explore our database:
- Install the extension: https://marketplace.visualstudio.com/items?itemName=Evidence.sqltools-duckdb-driver
- During and after the installation the extension it will probably ask you to confirm the installation of some tools.
- Setup the connection with the duckdb database file:
- In the sqltool extension menu click on add connection:
- Fill info in connection settings, you can keep the connection name to DuckDB or give it a more meaningfull name.
- You should find a file named
dbt.duckdb
in the folder ofdbt_intro_da
if the commanddbt run
finished without errors. - Confirm the connection with
CONNECT NOW
- Browse the database, in
main/view
you should findlocal_sales
. You can then click on the magnifier icon to showlocal_sales
data - You should then see a VScode window with the following. From it you can explore, sort and filter data.
- You can also run custom query to explore de data present in the database: