1. Creating a Project

The following will discuss:

  • Creating a dbt project

  • DataWarehouse Credentials

You can find the video overview of this Project Creation section here

1.1. Creating a Repo

One can initialize the project through initializing a dbt project, with respective configurations.

dbt init

We see that we create a repository/folder with dbt configurations through the following command:

dbt init {project-name}

Think of it like a cookie cutter implementation to create standard dbt repo.

1.1.1. [Optional] Instantiating with an Adapter

If you have dbt version 0.18+, then you can create a profile yml file in your directory, whilst creating the dbt repo.

How?

There is an option to add an adapter via the adapter flag, seen below

dbt init {project-name} --adapter {some adapter}

More information about adapters can be found here

But why is this file important?

1.2. Credentials

A profiles.yml file for your dbt workflow is a configuration file for storing your particular credentials for executing dbt within your datawarehouse instances.

dbt works as the transformation within your warehouse, and leverages said warehouse for such transformations.

You can see if you have your profile by going to the following directory

cd ~/.dbt

After, enter ls to see if you have a .profile.yml file in there. If not, please create one.

The following is an example profile for a Cloud Data Platform Snowflake setup.

dbt profiles path

Thereafter, you can enter this file through your code editor, vim, or emac.

Here is a vim example, for Terminal

vim profiles.yml

In it, you’ll find a default configuration path for a Redshift example, seen below.


# For more information on how to configure this file, please see:
# https://docs.getdbt.com/docs/profile

default:
  outputs:
    dev:
      type: redshift
      threads: 1
      host: 127.0.0.1
      port: 5439
      user: alice
      pass: pa55word
      dbname: warehouse
      schema: dbt_alice
    prod:
      type: redshift
      threads: 1
      host: 127.0.0.1
      port: 5439
      user: alice
      pass: pa55word
      dbname: warehouse
      schema: analytics
  target: dev
                    

Again, recall we will be working within snowflake. So, the Snowflake configuration path would like as such:

customer-analytics-db:
  target: dev
  outputs:
    dev:
      type: snowflake
      account: {Some cool account name}

      # User/password auth
      user: {Super rad username}
      password: {3.1415926535897932384626433832795}

      role: ROLENAME
      database: DEMO_DB
      warehouse: COMPUTE_WH
      schema: dev_{ldap}
      threads: 1
      client_session_keep_alive: False
    prod:
      type: snowflake
      account: {Some cool account name}

      # User/password auth
      user: {Super rad username}
      password: {3.1415926535897932384626433832795}

      role: ROLENAME
      database: DEMO_DB
      warehouse: COMPUTE_WH
      schema: {official-database}
      threads: 1
      client_session_keep_alive: False

Now…