PostgreSQL node
The PostgreSQL node (type DATABASE_POSTGRESQL) executes SQL queries on a PostgreSQL database directly from a workflow. It is used to read or write data (SELECT, INSERT, UPDATE, DELETE, DDL), to enrich the context before an HTTP node or a business processing, and to persist data received by a trigger (webhook, Scheduler, file, etc.).
Parameters
| Parameter | Type | Required | Default | Description |
|---|---|---|---|---|
| App | App | ❌ | — | Application associated with the node. See Apps. |
Host (host) | String | ✅ | — | Hostname or address of the PostgreSQL server. Supports Handlebars. |
Port (port) | Number | ✅ | — | Connection port (often 5432). Supports Handlebars. |
Database (database) | String | ✅ | — | Name of the database. |
| Authentication | Credential | ✅ | — | Direct user/password or Ecosystem credential (BASIC_AUTH). |
SQL query (query) | String | ✅ | — | SQL query with Handlebars templating. Use $1, $2, … for the bound parameters. |
Binds (binds) | List (jsonpath) | ❌ | — | List of jsonpath expressions evaluated at execution ($.context.userId, etc.). |
| SSL | TLS options | ❌ | — | TLS options: ca, key, cert, rejectUnauthorized. |
Timeout (timeoutSeconds) | Number (seconds) | ❌ | 30 | Maximum delay in seconds (default 30, max 300). |
Output key (outputKey) | String | ❌ | postgresqlResult | Context key for the result. |
| Stop the workflow on failure | Boolean | ❌ | true | Workflow stop in case of SQL or connection error. |
Query and bound parameters
The dynamic values are injected via positional binds:
SELECT * FROM users WHERE id = $1 AND status = $2
Always use binds ($1, $2, …) rather than concatenating values in the SQL, and store the passwords in dictionaries or authentication methods. Adjust timeoutSeconds for heavy queries or nightly batches.
Input
The node receives the workflow context values via positional binds ($1, $2, …) evaluated at execution, and Handlebars templating in the query:
{
"binds": ["$.context.userId", "$.context.status"]
}
The "falsy" values (0, false, '', null) are kept as they are.
Output
The result is stored in context.<outputKey>:
| Property | Description |
|---|---|
rows | Rows returned by the query |
rowCount | Number of affected rows |
command | Type of SQL command executed |
fields | Column names |
Example of result for outputKey: "postgresqlResult":
{
"postgresqlResult": {
"rows": [
{ "id": 1, "email": "user1@example.com", "created_at": "2023-01-01" },
{ "id": 2, "email": "user2@example.com", "created_at": "2023-01-02" }
],
"rowCount": 2,
"command": "SELECT",
"fields": ["id", "email", "created_at"]
}
}
The result is consumable in the following nodes via {{postgresqlResult.rows}}, {{postgresqlResult.rowCount}}, or {{postgresqlResult.rows[0].email}} — for example in a Send an email node or a ForEach loop that iterates over rows.
Errors
In case of SQL or connection error, the node fails and stops the workflow execution (option Stop the workflow on failure, default true). To handle the failure cleanly, add an On Error node to the workflow.
See also: Best practices — Error management.
Limits
- Maximum timeout of 300 seconds (default
30). - Adjust
timeoutSecondsfor heavy queries or nightly batches.
Example
Read users and use them in the rest of the workflow:
- A trigger starts the workflow.
- The PostgreSQL node executes
SELECT * FROM users WHERE id = $1 AND status = $2with the binds$.context.userIdand$.context.status. - The result is available via
{{postgresqlResult.rows}}— for example a ForEach loop iterates overrows, or a Send an email node uses{{postgresqlResult.rows[0].email}}.