Setup instructions#
To get started with the tutorial, we recommend a GitHub Codespace. The template can be found at MotherDuck-Open-Source/dbt-tutorial-template.
If you feel like using your own local environment or another IDE, take a look at the Makefile
in the template repo.
For support during the workshop, please join us at slack.motherduck.com in the #smalldata-2024 channel.
Getting Started with Codespaces#
Create a MotherDuck account.
Fork the
dbt-tutorial-template
repo in GitHub.Generate an access token inside of MotherDuck and add it as a codespace secret inside of GitHub.
note: it is important that this token is called
MOTHERDUCK_TOKEN
so that it can be read by the MotherDuck DuckDB extension.
Open a codespace on your forked repo by clicking the big green “code” button your repo.
note: codespaces do not work on Safari. Use Chrome, Edge or Visual Studio Code.
After it loads completely, reload the window in order to make sure the dbt power user extension has access to your md environment.
python dependencies are added in a post create hook, and the default 2-core codespace is quite slow.
run
dbt init
to create your dbt project. Create a new project calledmy_project
, or use your preferred name.Navigate to the folder created in step 7 (e.g.
my_project
) and add thisprofiles.yml
file. This will be the folder that create in the previous step.# replace "my_project" with the name that matches the project name in step 6. my_project: outputs: dev: type: duckdb schema: main path: md:my_db threads: 1 local: type: duckdb schema: main path: local.duckdb threads: 1 target: dev
run
dbt debug
to validate that your setup is correct.note: you will need to be in the same directory as your
dbt_project.yml
file.
Alternative setup#
If you are feeling adventurous, you can run this same tutorial on your own laptop. At a minimum, you will need the libraries described in the requirements.txt
in the dbt-tutorial. After completing your environment set up (don’t forget to use a venv), run dbt init
.
In order for dbt power user
vscode extension to work properly with MotherDuck, you need to add your MOTHERDUCK_TOKEN
to your environment.
Adding a Token to Your Environment Variables#
macOS#
Open the Terminal.
Edit your shell profile:
If you’re using
bash
(default in older versions of macOS), run:nano ~/.bash_profile
If you’re using
zsh
(default in macOS Catalina and later), run:nano ~/.zshrc
Add the following line to the file:
export API_TOKEN="your_token_value"
Windows#
Press
Win + S
and search for Environment Variables.Select Edit the system environment variables.
In the System Properties window, click on Environment Variables.
In the User variables or System variables section, click New.
In the New Variable dialog:
Enter the variable name (e.g.,
API_TOKEN
).Enter the token value (e.g.,
your_token_value
).
Click OK to close all windows.
To verify, open a Command Prompt and type:
echo %API_TOKEN%
Linux#
Its probably better for you to write this tutorial than for me.