Skip to main content

Overview

Write data to PostgreSQL databases with automatic table creation and upsert support.

Configuration

sinks:
  my_postgres_sink:
    type: postgres
    from: my_transform
    schema: public
    table: my_table
    secret_name: MY_POSTGRES_SECRET
    primary_key: id # Optional - for upsert behavior

Parameters

type
string
required
Must be postgres
from
string
required
The transform or source to read data from
schema
string
required
PostgreSQL schema name (e.g., public, analytics)
table
string
required
Table name to write to. Will be created automatically if it doesn’t exist.
secret_name
string
required
Name of the secret containing the PostgreSQL connection string
primary_key
string
Optional. Column to use for upserts. If specified, existing rows will be updated instead of inserted.

Secret Format

The secret should contain a PostgreSQL connection string:
postgres://username:password@host:port/database
Create it with:
goldsky secret create MY_POSTGRES_SECRET

Features

  • Auto Table Creation: Tables are created automatically based on your data schema
  • Upsert Support: Use primary_key to update existing rows
  • Type Handling: Automatic type conversion from Arrow to PostgreSQL types
  • Large Numbers: U256/I256 types are stored as NUMERIC(78,0)

Example

sinks:
  postgres_transfers:
    type: postgres
    from: filtered_transfers
    schema: public
    table: erc20_transfers
    secret_name: MY_POSTGRES
    primary_key: id