Skip to content

PostgreSQL Query

Executes a PostgreSQL SELECT query through Salt’s CData-backed database service. It uses provided credentials to connect to a PostgreSQL database, sends the SQL to the service, and returns a formatted summary along with the raw results. This node is read-focused and intended for retrieving data, not performing INSERT/UPDATE/DELETE operations.
Preview

Usage

Use this node when you need to fetch records from a PostgreSQL database as part of a workflow (e.g., pulling rows for analysis or feeding downstream processing). Provide a valid credentials file for the PostgreSQL connection and a SELECT statement. The node will call the backend service and return a readable text summary and structured results suitable for further steps.

Inputs

FieldRequiredTypeDescriptionExample
credentials_pathTrueNot specifiedPath to the saved PostgreSQL credential configuration used by the service to authenticate and connect./workspace/credentials/postgres.json
timeoutFalseNot specifiedMaximum time in seconds to wait for the query request before timing out.60
sql_textTrueSTRINGThe SQL SELECT query to execute against PostgreSQL.SELECT id, email FROM users WHERE created_at >= '2024-01-01' LIMIT 100

Outputs

FieldTypeDescriptionExample
textNot specifiedA human-readable summary of the query results suitable for display.PostgreSQL Query Results: 100 rows returned.
jsonNot specifiedRaw results from the service as structured data for downstream processing.{"rows": [{"id": 1, "email": "user@example.com"}], "row_count": 1}

Important Notes

  • Query type: Designed for SELECT queries only. Use a separate execute node for INSERT/UPDATE/DELETE.
  • Credentials required: You must supply a valid PostgreSQL credential file that the service recognizes.
  • Timeouts and large results: Complex or large queries may require increased timeouts or result limiting.
  • Service-backed: The node routes requests to a backend service endpoint ("/query"); connectivity and service availability affect results.
  • Result formatting: Returns both a readable summary and structured data to support human review and automated use.

Troubleshooting

  • Invalid SQL or syntax errors: Verify the SQL is a valid SELECT statement and test it directly in your database; ensure references to schemas/tables are correct.
  • Authentication or connection failures: Check the credentials_path points to a valid PostgreSQL configuration and that network/firewall settings allow service access.
  • Timeouts: Increase the timeout input or optimize the query with indexes, filters, or LIMIT.
  • Empty results: Confirm the query conditions and that the connected database/schema contains the expected data.
  • Permission errors: Ensure the configured database user has SELECT privileges on the target tables/views.