PostgreSQL - Query
Execute SQL queries on PostgreSQL databases.
Runs one SQL statement on PostgreSQL with positional $1, $2… parameters and returns the rows under result, or routes to empty when no rows come back.
Connect your PostgreSQL instance and run parameterized queries with $1, $2 positional binding for SQL injection prevention. Compatible with PostgreSQL, CockroachDB, Supabase, and Neon.
Operations:
- SELECT: Fetch rows from tables with filters, joins, and aggregations. Returns empty port when no results.
- INSERT: Add new records to tables with RETURNING support.
- UPDATE: Modify existing records matching a condition.
- DELETE: Remove records from tables.
- Functions: Call PL/pgSQL functions and stored procedures.
- DDL: Execute CREATE, ALTER, DROP statements for schema management.
How it works
- Resolves the expressions of the node config. Empty
connection_idandsqlfall back to the incoming item. Parameters are read fromparams, thenparameters, then the incoming item'sparamsorparameters. - Resolves the connection: a
postgres:///postgresql://URI inconnection_id, aconnection-stringcredential, or abasic-auth/objectcredential withusername,password,host,databaseandport(default 5432). - Connects, runs
sqlwith the parameters (a single non-array value is wrapped in an array) and closes the connection. - Returns
{ result: rows }onout, or{ result: [] }onemptywhen no rows are returned.
In a workflow
The node as it appears in a workflow file (draft_nodes[]), and the envelope of a successful run.
{
"node_id": "node-find-customer",
"label": "Find customer",
"operator_slug": "integrations.postgresql.query",
"operator_version": "1.0.0",
"config": {
"connection_id": "pi-credential-xxxx",
"sql": "SELECT id, email, created_at FROM customers WHERE email = $1",
"parameters": [
"{{ $json.email }}"
]
}
}{
"ok": true,
"data": {
"result": [
{
"id": 42,
"email": "[email protected]",
"created_at": "2026-11-20T15:04:05.000Z"
}
]
},
"port": "out"
}Configuration
-
connection_idstring Required -
Credential for your PostgreSQL instance. Accepts credentials of type `connection-string` (postgres:// URI) or `basic-auth` (username + password + host + database).
-
sqlstring Required Accepts expressions -
The SQL statement to execute (e.g., "SELECT * FROM users WHERE id = $1").
-
parametersarray Optional -
Array of values for positional $1, $2, ... parameter binding.
Behaviour in the code
What the implementation does with these keys beyond what the schema says.
-
paramsRead by the code, not declared - Undeclared alias of
parametersthat takes precedence when both are set. -
connection_id - With a connection string, TLS is used without certificate verification except for localhost (no TLS). With a structured credential, TLS is used only when the credential config sets
ssl.
Output ports
out default The statement returned at least one row.
{
"result": [
{
"id": 42,
"email": "[email protected]",
"created_at": "2026-11-20T15:04:05.000Z"
}
]
}empty The statement returned no rows. This includes INSERT, UPDATE and DELETE without RETURNING.
{
"result": []
}error Validation, credential resolution, the connection or the statement failed.
{
"error": "relation \"customers\" does not exist"
}In expressions
What a later node can read from this node's output with $("PostgreSQL - Query").item.json.<path> (write your node's label instead of PostgreSQL - Query). Editor marks the paths the workflow editor suggests under Previous Nodes (the output contract); Worker marks the paths the worker really returns through out, from the output shown in Ports.
| Expression | Editor | Worker |
|---|---|---|
$("PostgreSQL - Query").item.json.resultArray of rows returned by the query |
Errors
| Message | Port | Cause and fix |
|---|---|---|
connection_id is required | error | No credential in the config or in the incoming item. |
sql query is required | error | sql is empty. |
bind message supplies <n> parameters, but prepared statement "" requires <m> | error | The number of parameters does not match the $n placeholders in sql. |
Credential <connection_id> has unsupported type '<type>' for integrations.postgresql.query. Use 'connection-string' or 'basic-auth'. | error | The credential type is not supported by this node. |
Input contract
-
connection_idstring Required -
sqlstring Required -
parametersarray Optional
Output contract
-
resultarray<object> Optional -
Array of rows returned by the query
Contracts (JSON Schema)
The definition exactly as the orchestrator declares it. All is the whole *.definition.js; compare it with the sections above to spot differences between the documentation and the schema. Use it to validate a node before you publish.
{
"slug": "integrations.postgresql.query",
"name": "PostgreSQL - Query",
"category": "integrations",
"version": "1.0.0",
"description": "Execute SQL queries on PostgreSQL databases.\n\n Connect your PostgreSQL instance and run parameterized queries with $1, $2 positional binding for SQL injection prevention. Compatible with PostgreSQL, CockroachDB, Supabase, and Neon.\n\n **Operations:**\n - **SELECT:** Fetch rows from tables with filters, joins, and aggregations. Returns empty port when no results.\n - **INSERT:** Add new records to tables with RETURNING support.\n - **UPDATE:** Modify existing records matching a condition.\n - **DELETE:** Remove records from tables.\n - **Functions:** Call PL/pgSQL functions and stored procedures.\n - **DDL:** Execute CREATE, ALTER, DROP statements for schema management.",
"capabilities": [
"sql",
"database",
"postgres",
"postgresql"
],
"group": [
{
"key": "postgresql",
"name": "PostgreSQL",
"icon_url": "/icons/integrations/postgresql/postgresql.svg"
}
],
"icon_url": "/icons/integrations/postgresql/postgresql.svg",
"config_schema": {
"type": "object",
"properties": {
"connection_id": {
"type": "string",
"title": "PostgreSQL Credential",
"description": "Credential for your PostgreSQL instance. Accepts credentials of type `connection-string` (postgres:// URI) or `basic-auth` (username + password + host + database).",
"ui_widget": "connection_picker",
"ui_options": {
"credential_types": [
"connection-string",
"basic-auth"
],
"types": [
"postgres"
]
}
},
"sql": {
"type": "string",
"title": "SQL Query",
"description": "The SQL statement to execute (e.g., \"SELECT * FROM users WHERE id = $1\").",
"format": "expression",
"ui_widget": "sql_editor"
},
"parameters": {
"type": "array",
"title": "Query Parameters",
"description": "Array of values for positional $1, $2, ... parameter binding."
}
},
"required": [
"connection_id",
"sql"
]
},
"input_contract_schema": {
"type": "object",
"properties": {
"connection_id": {
"type": "string"
},
"sql": {
"type": "string"
},
"parameters": {
"type": "array"
}
},
"required": [
"connection_id",
"sql"
]
},
"output_contract_schema": {
"type": "object",
"properties": {
"result": {
"type": "array",
"items": {
"type": "object"
},
"description": "Array of rows returned by the query"
}
}
},
"ports": [
{
"port_id": "out",
"label": "Rows",
"description": "Resulting rows from the query",
"is_default": true,
"supports_condition": true
},
{
"port_id": "empty",
"label": "Empty",
"description": "No rows returned",
"is_default": false,
"supports_condition": true
},
{
"port_id": "error",
"label": "Error",
"description": "Error occurred during execution",
"is_default": false,
"supports_condition": false
}
],
"execution_mode": "async",
"required_resources": [],
"compatible_worker_pools": [
"standard-io",
"db-io"
],
"tags": [
"sql",
"database"
],
"is_stateful": false,
"publisher": {
"identity": "org_sommatic_ai",
"profile": {
"name": "Sommatic AI",
"verified": true,
"url": "https://sommatic.ai",
"logo_url": null
}
}
}{
"type": "object",
"properties": {
"connection_id": {
"type": "string",
"title": "PostgreSQL Credential",
"description": "Credential for your PostgreSQL instance. Accepts credentials of type `connection-string` (postgres:// URI) or `basic-auth` (username + password + host + database).",
"ui_widget": "connection_picker",
"ui_options": {
"credential_types": [
"connection-string",
"basic-auth"
],
"types": [
"postgres"
]
}
},
"sql": {
"type": "string",
"title": "SQL Query",
"description": "The SQL statement to execute (e.g., \"SELECT * FROM users WHERE id = $1\").",
"format": "expression",
"ui_widget": "sql_editor"
},
"parameters": {
"type": "array",
"title": "Query Parameters",
"description": "Array of values for positional $1, $2, ... parameter binding."
}
},
"required": [
"connection_id",
"sql"
]
}{
"type": "object",
"properties": {
"connection_id": {
"type": "string"
},
"sql": {
"type": "string"
},
"parameters": {
"type": "array"
}
},
"required": [
"connection_id",
"sql"
]
}{
"type": "object",
"properties": {
"result": {
"type": "array",
"items": {
"type": "object"
},
"description": "Array of rows returned by the query"
}
}
}[
{
"port_id": "out",
"label": "Rows",
"description": "Resulting rows from the query",
"is_default": true,
"supports_condition": true
},
{
"port_id": "empty",
"label": "Empty",
"description": "No rows returned",
"is_default": false,
"supports_condition": true
},
{
"port_id": "error",
"label": "Error",
"description": "Error occurred during execution",
"is_default": false,
"supports_condition": false
}
]Execution
- Execution
async- Stateful
- No
- Credentials
- Resolved on the server from
connection_id; the secret never reaches the workflow. - Capabilities
sqldatabasepostgrespostgresql- Tags
sqldatabase
Notes and limits
- Use
RETURNINGon writes if you needout; otherwise they always route toempty. - A new connection is opened and closed on every run; the node does not retry.
Reviewed against the orchestrator code · 31e874b · 2026-11-26