# Postgres Integration

> Connect any Postgres warehouse as a behavioral data source. Replicas, Supabase, self-hosted — Beton reads schema and discovers signals directly.

*Source: [https://www.getbeton.ai/integrations/postgres/](https://www.getbeton.ai/integrations/postgres/)*

**Category:** source
**Vendor URL:** https://www.postgresql.org/

## How it works

1. **Connect a read-only role** — Provide a connection string. Beton uses a single read-only role and never writes back. Your Postgres takes no extra load — Beton schedules its own scans on a quiet replica or off-peak window.
2. **Beton proposes hypotheses** — The agent reads schema (tables, columns, foreign keys) and proposes testable behavioral hypotheses tailored to YOUR table layout — no generic templates.
3. **Backtest before promotion** — Each hypothesis is validated against historical rows: precision, recall, lift over baseline. Promote only the ones that beat your bar.

## Features

- Read-only connection — zero impact on production
- Works with managed Postgres (RDS, Cloud SQL), Supabase, and self-hosted
- Automatic schema introspection — no manual table mapping
- Compatible with warehouse loaders like Fivetran, Segment, RudderStack
- Same hypothesis-and-backtest flow as PostHog
- No data export or migration required

## Use cases

- Run signal discovery on a production replica
- Use Beton on warehouse data piped from Segment / Fivetran / RudderStack
- Cross-reference event data with internal product tables (subscriptions, deals, support tickets)
- Run signal hunts on Supabase-backed apps

## Setup snippet

*Provision a read-only role for Beton (run in psql)*

```bash
CREATE ROLE beton_readonly LOGIN PASSWORD '<random>';
GRANT CONNECT ON DATABASE your_db TO beton_readonly;
GRANT USAGE ON SCHEMA public TO beton_readonly;
GRANT SELECT ON ALL TABLES IN SCHEMA public TO beton_readonly;
ALTER DEFAULT PRIVILEGES IN SCHEMA public
  GRANT SELECT ON TABLES TO beton_readonly;
```
