# dbt

## Configuration

prism enables users to build analytics on top of dbt projects. The configurations for a dbt connection are:

* `project_dir:` the directory to your dbt project
* `profiles_dir`: the directory to your dbt profile. If one isn't specified, then prism assumes the default dbt profile directory `~/.dbt`
* `profiles_target`: the profile target you wish to use. More information can be found in the [dbt documentation](https://docs.getdbt.com/dbt-cli/configure-your-profile). If your profile has only one target, then this does not need to be specified.

```yaml
# profile.yml

<profile name here>: # change this!
  adapters:
    <dbt adapter name here>: # change this!
      type: dbt
      project_dir:
      profiles_dir:
      profiles_target:

```

Under the hood, prism interacts with the dbt architecture to create the project, compile the manifest, getting the target and SQL adapter, and executing the query.

## `hooks.dbt_ref()`

Once connected to a dbt project, users can access dbt models using the `hooks.dbt_ref` function. This function behaves exactly as the `ref` function does in dbt. It takes as input a model from your dbt project or a package model and returns it as a pandas DataFrame.

```python
def run(self, tasks, hooks):
    df1 = hooks.dbt_ref('model_name') # Model from your project
    df2 = hooks.dbt_ref('package_name', 'model_name') # Package model
```

{% hint style="warning" %}
**Warning:** `hooks.dbt_ref` does NOT materialize your models for you! You'll need to materialize them yourselve (e.g., with `dbt run`) before using Prism's hooks.
{% endhint %}
