New260+ blocks and 240+ tools are now fully documented
DocumentationReferenceCore BlocksDatabases
Block

PostgreSQL Block

Execute SQL queries and manage data in PostgreSQL databases

The PostgreSQL block connects to a PostgreSQL database to execute raw SQL queries and perform full CRUD operations (insert, update, delete) on your data. Reach for it when a workflow needs to read from or write to a relational database, with support for secure SSL connections and parameterized queries.

Overview

PropertyValue
Typepostgresql
Categorytools
Color#336791

When to Use

  • Run a custom SELECT query to pull rows into your workflow for downstream blocks.
  • Insert one or many new records into a table from data produced earlier in the workflow.
  • Update existing rows that match a set of WHERE conditions.
  • Delete rows that match given conditions.
  • Connect to a managed/cloud Postgres instance over SSL/TLS.
  • Persist agent or workflow output into application tables for later retrieval.

Configuration

Host

PostgreSQL hostname or IP address (e.g. localhost or db.example.com). Required.

Port

PostgreSQL port. Defaults to 5432.

Database

Target database name. Required.

Username

Database username. Required.

Password

Database password. Leave empty for trust/peer authentication.

Enable SSL

Switch to use SSL/TLS encryption for the connection.

Action

Dropdown selecting the operation: Execute Query (execute), Insert Data (insert), Update Data (update), or Delete Data (delete). Defaults to execute.

SQL Query

The raw SQL to run. Shown when the action is execute. Supports a generation assistant for producing PostgreSQL-correct queries.

Table Name

Target table for insert, update, and delete actions.

Data

JSON object (or array of objects) with the values to write. Shown for insert and update actions.

Conditions (WHERE clause)

JSON object defining the WHERE conditions. Shown for update and delete actions.

Inputs & Outputs

  • Inputs:
    • host (string) — PostgreSQL hostname or IP address
    • port (number) — PostgreSQL port (default: 5432)
    • database (string) — Target database name
    • username (string) — Database username
    • password (string) — Database password
    • ssl (boolean) — Enable SSL/TLS connection
    • action (string) — Operation to perform: execute, insert, update, or delete
    • query (string) — SQL query to execute (used with execute action)
    • table (string) — Table name for insert, update, and delete actions
    • data (json) — Data object or array of objects for insert and update actions
    • conditions (json) — WHERE conditions for update and delete actions
  • Outputs:
    • data (json) — Query results returned by SELECT operations
    • affectedRows (number) — Number of rows affected by INSERT, UPDATE, or DELETE operations
    • metadata (json) — Query execution metadata including timing and row counts
    • error (string) — Error message if the operation fails
    • errorDetails (json) — Detailed error information including error type and execution time

Tools

PostgreSQL (postgresql_database) — Executes SQL queries and manages data in PostgreSQL databases. Supports raw query execution, parameterized inserts, condition-based updates and deletes, and connection pooling with optional SSL. Calls the /api/tools/postgresql endpoint internally.

YAML Example

postgresql_1:
  type: postgresql
  name: "PostgreSQL"
  inputs:
    host: "db.example.com"
    port: 5432
    database: "my_database"
    username: "postgres"
    password: "{{ENV_DB_PASSWORD}}"
    ssl: true
    action: "execute"
    query: "SELECT * FROM users WHERE active = true"
  connections:
    outgoing:
      - target: next-block-id