Skip to main content

Quickstart for dbt Core using GitHub Codespaces

dbt Core
Quickstart
Beginner
Menu

    Introduction

    In this quickstart guide, you’ll learn how to create a codespace and be able to execute the dbt build command from it in less than 5 minutes.

    dbt Labs provides a GitHub Codespace template that you (and anyone else) can reuse to create a complete dbt environment with a working and runnable project. When you create the codespace, the dev container creates a fully functioning dbt environment, connects to a DuckDB database, and loads a year of data from our fictional Jaffle Shop café, which sells food and beverages in several US cities. The README for the Jaffle Shop template also provides instructions on how to do this, along with animated GIFs.

    Prerequisites

    • To use the dbt command-line interface (CLI), it's important that you know some basics of the terminal. In particular, you should understand cd, ls , and pwd to navigate through the directory structure of your computer easily.
    • You have a GitHub account.

    Create a codespace

    1. Go to the jaffle-shop-template repository after you log in to your GitHub account.

    2. Click Use this template at the top of the page and choose Create new repository.

    3. Click Create repository from template when you’re done setting the options for your new repository.

    4. Click Code (at the top of the new repository’s page). Under the Codespaces tab, choose Create codespace on main. Depending on how you've configured your computer's settings, this either opens a new browser tab with the Codespace development environment with VSCode running in it or opens a new VSCode window with the codespace in it.

    5. Wait for the codespace to finish building by waiting for the postCreateCommand command to complete; this can take several minutes:

      Wait for postCreateCommand to completeWait for postCreateCommand to complete

      When this command completes, you can start using the codespace development environment. The terminal the command ran in will close and you will get a prompt in a brand new terminal.

    6. At the terminal's prompt, you can execute any dbt command you want. For example:

      /workspaces/test (main) $ dbt build

      You can also use the duckcli to write SQL against the warehouse from the command line or build reports in the Evidence project provided in the reports directory.

      For complete information, refer to the dbt command reference. Common commands are:

      • dbt compile — generates executable SQL from your project source files
      • dbt run — compiles and runs your project
      • dbt test — compiles and tests your project
      • dbt build — compiles, runs, and tests your project

    Generate a larger data set

    If you'd like to work with a larger selection of Jaffle Shop data, you can generate an arbitrary number of years of fictitious data from within your codespace.

    1. Install the Python package called jafgen. At the terminal's prompt, run:

      /workspaces/test (main) $ python -m pip install jafgen
    2. When installation is done, run:

      /workspaces/test (main) $ jafgen --years NUMBER_OF_YEARS

      Replace NUMBER_OF_YEARS with the number of years you want to simulate. This command builds the CSV files and stores them in the jaffle-data folder, and is automatically sourced based on the sources.yml file and the dbt-duckdb adapter.

    As you increase the number of years, it takes exponentially more time to generate the data because the Jaffle Shop stores grow in size and number. For a good balance of data size and time to build, dbt Labs suggests a maximum of 6 years.

    0