dbt-postgres

The official dbt adapter that lets dbt compile and run SQL transformations against PostgreSQL.

SDK
PyPI
v1.11.0
232stars
Apache License 2.0

Repository Health

Pre-computed score based on development activity, maintenance, community, maturity, and trend momentum.How we score it →
88/100Excellent
Development Activity96
Maintenance96
Community80
Maturity52
Momentum28

Technical Analysis

AI-assessed by reading the actual repository — architecture, code quality, innovation, and documentation.How we score it →
70/100Good
Architecture78
Code Quality76
Innovation60
Learning Curve64

dbt-postgres is the first-party adapter that connects dbt (data build tool) to PostgreSQL databases. It translates dbt’s model compilation, materialization strategies, and macros into Postgres-compatible SQL, letting analytics engineers run version-controlled, testable transformation pipelines directly against a Postgres warehouse. It ships as part of the dbt-labs/dbt-adapters monorepo alongside adapters for Snowflake, BigQuery, Redshift, and other warehouses.

What You Get

  • A Postgres-specific dbt adapter implementing connections, relations, and column introspection via psycopg2
  • Materialization macros (table, view, incremental, snapshot, materialized view) tuned for Postgres SQL syntax
  • Automatic dependency management pulling in dbt-core, dbt-adapters, dbt-common, and agate at compatible versions
  • Support for Postgres-specific features like materialized views and index management from dbt config
  • Continuous compatibility testing against new dbt-core releases via the shared dbt-adapters monorepo test suite

Common Use Cases

  • Running dbt transformation pipelines against a self-hosted or managed Postgres data warehouse
  • Local development and CI testing of dbt projects using Postgres as a lightweight substitute for a cloud warehouse
  • Building analytics engineering workflows (staging → intermediate → mart models) on top of an existing Postgres application database
  • Powering dbt Cloud or dbt Core scheduled jobs that target Postgres as the target adapter

Under The Hood

Architecture: dbt-postgres is a thin adapter layer over dbt-adapters’ base adapter protocol, implementing a PostgresAdapter (impl.py), PostgresConnectionManager (connections.py), and PostgresRelation/PostgresColumn classes that plug into dbt-core’s plugin discovery system; SQL generation is driven by Jinja macros under src/dbt/include/postgres/macros covering materializations, catalog queries, and cross-database utility functions like dateadd/datediff/listagg. Tech Stack: Pure Python 3.10+, built with hatchling, depending on psycopg2-binary for the DB driver, dbt-adapters/dbt-common for the shared adapter contract, and agate for in-memory result handling; the package is one of six first-party adapters in the dbt-labs/dbt-adapters monorepo, released independently but tested together via a shared CI pipeline. Code Quality: The repo enforces black formatting and mypy type checking, has dedicated tests/unit and tests/functional suites run via pytest with parallel execution (-n auto), and dependency version ranges are pinned conservatively (e.g. dbt-core>=1.8.0rc1,<2.0) to avoid breaking installs. API Design: Developers rarely import dbt-postgres directly — it’s installed as a dbt plugin and configured entirely through a profiles.yml connection block (host/port/user/password/dbname), so the real ergonomics surface is macro coverage and error messages during dbt run, which are generally clear and Postgres-specific.

Join founders buildingwith open source

Opinionated takes, migration guides, cost-saving tips, and insights from the open source ecosystem.

Subscribe on Substack
Join 750+ subscribers

Search