dbt-adapters

1.22.9 · active · verified Sat Mar 28

dbt-adapters is a Python library that defines the set of adapter protocols and base functionality crucial for integrating dbt-core with various data platforms. It serves as the foundational interface for developing database-specific dbt adapters. As of its current version 1.22.9, it's an actively developed component within the dbt ecosystem, with a release cadence that is increasingly independent of dbt-core, especially since dbt-core v1.8.

Warnings

Install

Imports

Quickstart

dbt-adapters is a low-level library for building dbt adapters. End-users interact with adapter functionality through dbt-core and specific database adapters. The quickstart below illustrates how a dbt user sets up a project and uses adapter-specific logic via Jinja macros in a SQL model, which leverages the interfaces provided by `dbt-adapters`.

# 1. Install dbt-core and your specific database adapter (e.g., dbt-postgres)
# pip install dbt-core dbt-postgres

# 2. Initialize a dbt project
# dbt init my_dbt_project
# cd my_dbt_project

# 3. Configure your profiles.yml (typically in ~/.dbt/profiles.yml)
# Example profiles.yml content (replace with your database details):
# my_dbt_project:
#   target: dev
#   outputs:
#     dev:
#       type: postgres
#       host: localhost
#       user: myuser
#       password: "{{ env_var('DB_PASSWORD') }}"
#       port: 5432
#       dbname: mydatabase
#       schema: public

# 4. Create a dbt model (e.g., models/my_model.sql)
# Use the 'adapter' object in Jinja to call adapter-specific functionality.
# For instance, to get the current timestamp, which might vary by database dialect:
-- my_model.sql
SELECT
    {{ adapter.dispatch('current_timestamp', 'dbt')() }} as current_time,
    1 as id

view raw JSON →