BlocksDatabase
PostgreSQL
Connect to and query your PostgreSQL database with a visual builder or raw SQL.
The PostgreSQL block allows you to manage data in your PostgreSQL database. It supports both a structured visual builder for common operations and raw SQL execution for advanced use cases.
Core Concept
PostgreSQL is a robust relational database. This block simplifies common tasks like finding or updating users, while also allowing you to use advanced PostgreSQL features via raw SQL queries with safe parameter injection.
Configuration
| Field | Required | Description |
|---|---|---|
| Connection | ✅ | Select your PostgreSQL database connection. |
| Operation | ✅ | Choose the action: Find One, Find Many, Insert One, Update, Delete, Count, or Raw SQL Query. |
| Table Name | ✅ | The name of the table to target (e.g., profiles). (Not used for Raw Query). |
| SQL Query | ✅ | (Raw Mode) Your SQL string. Use $1, $2, etc., as placeholders (e.g., SELECT * FROM users WHERE id = $1). |
| Query Parameters | — | (Raw Mode) List the values to replace the $1, $2, etc., placeholders in order. |
| Filter Conditions | — | Define the WHERE clause conditions using a visual builder. |
| Columns to Set | — | Define columns and values for INSERT or UPDATE operations. |
| Output Variable | ✅ | The variable to store the result rows or operation status. |
Parameter Syntax
Unlike MySQL which uses ?, PostgreSQL uses numbered placeholders like $1, $2. The first item in your Query Parameters list will replace $1.
Variable Syntax Rules
- Single braces only:
{variable_name}. - Library variables:
{MY_VAR}. - Request data:
{request.body.field}or{request.query.field}. - Never use
{{double_braces}}.
Error Handling
FIELD_MISSING— Triggered when required fields like Connection or Operation are missing.CONNECTION_FAILED— Triggered if the connection to the PostgreSQL server cannot be established.OPERATION_FAILED— Triggered if the SQL query contains errors or the database rejects the command.BUILDER_FAILED— Triggered if the visual builder fails to generate a valid SQL statement.
Example
- Setup: Select your "User Base" connection and set Table Name to
accounts. - Operation: Set Operation to
Update. - Filter: Add a condition where
idequals{request.body.user_id}. - Columns: Add
last_loginset to{CURRENT_TIMESTAMP}. - Variable: Set Output Variable to
update_status.
Result: The block updates the specific account and stores the operation summary in {update_status}.
