FluxyAPIFluxyAPI
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

FieldRequiredDescription
ConnectionSelect your PostgreSQL database connection.
OperationChoose the action: Find One, Find Many, Insert One, Update, Delete, Count, or Raw SQL Query.
Table NameThe 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 ConditionsDefine the WHERE clause conditions using a visual builder.
Columns to SetDefine columns and values for INSERT or UPDATE operations.
Output VariableThe 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

  1. Setup: Select your "User Base" connection and set Table Name to accounts.
  2. Operation: Set Operation to Update.
  3. Filter: Add a condition where id equals {request.body.user_id}.
  4. Columns: Add last_login set to {CURRENT_TIMESTAMP}.
  5. Variable: Set Output Variable to update_status.

Result: The block updates the specific account and stores the operation summary in {update_status}.

On this page