> ## Documentation Index
> Fetch the complete documentation index at: https://docs.elementary-data.com/llms.txt
> Use this file to discover all available pages before exploring further.

# Quickstart: Install Elementary dbt package

To use Elementary with dbt, add our dbt package to your dbt project.

> [!NOTE]
>
> **Note:** elementary dbt package has to be installed in all of the connected projects in your environment.

> [accordion] What are dbt packages and packages.yml?
>
> A dbt package is additional Jinja and SQL code that is added to your project, for additional functionality. In fact, each package is a dbt project. By adding a package to your project, you are adding the package code to be part of your project, you can reference its macros, execute its models, and so on.
>
> Add packages to your project by creating a `packages.yml` file under the main project directory (where your `dbt_project.yml` is), and adding the relevant package. After you add a new package, run `dbt deps` to actually pull its code to your project. This is also how you update packages.
> Some packages we recommend you check out: [dbt\_utils](https://github.com/dbt-labs/dbt-utils/tree/0.8.2/), [dbt\_date](https://github.com/calogica/dbt-date/tree/0.5.4/), [codegen](https://github.com/dbt-labs/dbt-codegen/tree/0.5.0/).

## Step-by-step: How to install the Elementary dbt package?

[https://www.loom.com/embed/5cf1aaa0708f43a993f8a2945473c7ac](https://www.loom.com/embed/5cf1aaa0708f43a993f8a2945473c7ac)

## Install Elementary dbt package

**1. Add elementary to `packages.yml`**

Add the following to your `packages.yml` file (if missing, create it where `dbt_project.yml` is):

```yml packages.yml theme={null}
packages:
  - package: elementary-data/elementary
    version: 0.26.1
    ## Docs: https://docs.elementary-data.com
```

**2. Add to your `dbt_project.yml`**

> [!NOTE]
>
> This means Elementary models will have their own schema.
> Depending on your project [custom schema macro](https://docs.getdbt.com/docs/build/custom-schemas), the schema will be named `elementary` or `<target_schema>_elementary`.
> Make sure your user has permissions to create schemas.

> [accordion] Important: Materialization config
>
> For elementary to work, it needs to create some of the models as incremental tables.
> Make sure that there are no global materialization configurations that affect elementary, such as:
>
> ```yml dbt_project.yml theme={null}
> materialized: "{{ 'table' if target.name == 'prod-cloud' else 'view' }}"
> ```
>
> Make sure to place the 'elementary' configuration under the models key, and other configs under your project name.
>
> Example:
>
> ```yml dbt_project.yml theme={null}
> models:
>   my_project:
>     materialized: "{{ 'table' if target.name == 'prod-cloud' else 'view' }}"
>
>   elementary:
>     +schema: "elementary"
> ```
>
> **If you change materialization settings, make sure to run `dbt run -s elementary --full-refresh`.**

> [accordion] Important: Allowing Elementary to override dbt's default test materializations (relevant from dbt 1.8)
>
> In order for these features to work, add the following file: elementary\_materialization.sql  to your macros folder so it will look like this:
> `macros/elementary_materialization.sql`
>
> In the file copy and paste the following code:
>
> If you use Snowflake:
>
> ```
> {% materialization test, adapter='snowflake' %}
>   {{ return(elementary.materialization_test_snowflake()) }}
> {% endmaterialization %}
> ```
>
> If you use any other DWH:
>
> ```
> {% materialization test, default %}
> {{ return(elementary.materialization_test_default()) }}
> {% endmaterialization %}
> ```

```yml dbt_project.yml theme={null}
models:
  ## see docs: https://docs.elementary-data.com/
  elementary:
    ## elementary models will be created in the schema '<your_schema>_elementary'
    +schema: "elementary"
    ## To disable elementary for dev, uncomment this:
    # enabled: "{{ target.name in ['prod','analytics'] }}"
```

**3. Import the package and build Elementary models**

```shell Terminal theme={null}
dbt deps
dbt run --select elementary
```

This will mostly create empty tables, that will be updated with artifacts, metrics and test results in your future dbt executions.

**4. Run tests**

Validate the installation by running some tests:

```shell Terminal theme={null}
dbt test
```

After you ran your tests, we recommend that you ensure that the results were loaded to `elementary_test_results` table.

## What happens now?

Once the elementary dbt package has been installed and configured, your test results, run results and [dbt artifacts](https://docs.elementary-data.com/data-tests/dbt/dbt-artifacts.md) will be loaded to elementary schema tables.

If you see data in these models you completed the package deployment (Congrats! 🎉).

Updating environment settings can take up to a few minutes.

## What's next?

Take a moment to ⭐️ [star our Github repo!](https://github.com/elementary-data/elementary) ⭐️ (It helps us a lot!)


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.