Skip to content

PostgreSQL Query

Executes a PostgreSQL SELECT query using provided database credentials. Returns a human-readable summary along with the raw JSON result data. Designed for read-only operations; mutations should use the corresponding execute node.
Preview

Usage

Use this node to retrieve data from a PostgreSQL database. Provide a credentials file path that matches the PostgreSQL credential template and a valid SQL SELECT statement. The node is typically placed early in a workflow to fetch data that subsequent nodes will analyze, transform, or visualize.

Inputs

FieldRequiredTypeDescriptionExample
credentials_pathTrueSTRINGPath to the stored PostgreSQL credentials file that follows the 'postgres' credential template (e.g., host, port, database, username, password)./path/to/credentials/postgres.json
timeoutTrueINTMaximum time in seconds to wait for the query to complete before timing out.60
sql_textTrueSTRINGThe SQL SELECT statement to execute against the PostgreSQL database.SELECT id, name, email FROM users LIMIT 10

Outputs

FieldTypeDescriptionExample
textSTRINGA short, human-readable summary title for the query result.PostgreSQL Query Results
jsonJSONRaw JSON data returned by the query for downstream processing.[{'id': 1, 'name': 'John Doe', 'email': 'john@example.com'}]

Important Notes

  • This node is intended for read-only operations (SELECT). For INSERT/UPDATE/DELETE, use SaltPostgresExecute.
  • Ensure the credentials file matches the 'postgres' credential template and contains valid connection details.
  • Large result sets may impact performance and could be truncated upstream or cause timeouts; consider adding LIMIT or filtering.
  • SQL must be valid for PostgreSQL dialect; parameterization is not supported in this node's interface.
  • Timeout applies to the entire request cycle; increase it for long-running queries.

Troubleshooting

  • Query fails with syntax error: Verify the SQL is valid PostgreSQL syntax and test it directly in a SQL client.
  • Authentication/connection error: Confirm credentials_path points to a valid file and that host/port/database/user/password are correct and reachable.
  • Request timed out: Increase the timeout value or optimize the query by adding indexes/filters/LIMIT.
  • Empty or unexpected results: Check the target schema/table and WHERE clauses; ensure the connected user has SELECT permissions.
  • Invalid credentials file format: Make sure the credentials JSON follows the expected 'postgres' template keys and structure.