Query Postgres Block

Execute SQL queries on a Postgres database within Scout workflows

The Query Postgres block enables users to execute SQL queries on a specified Postgres database within Scout workflows. This block is useful for retrieving data, performing database operations, and integrating database results into workflows. It supports dynamic query construction using Jinja templating.

Configuration (Required)

Connection String
stringRequired

The connection string is essential for establishing a connection to your Postgres database. Ensure this string is formatted correctly and has the necessary permissions to avoid connection issues.

SQL Query
codeRequired

The SQL query defines the specific command or set of commands you wish to execute against your Postgres database. This field supports Jinja templating, allowing for dynamic query construction based on workflow state.

See Workflow Logic & State > State Management for details on using dynamic variables in this block.

Outputs

The output of the Query Postgres block is a list of dictionaries representing the rows returned by the SQL query. Each dictionary corresponds to a row, with column names as keys. The block also provides details such as the response format and the time taken to execute the query in milliseconds.

Usage Context

Use this block to interact with Postgres databases directly from your workflow, allowing for dynamic data retrieval and manipulation.

Best Practices

  • Ensure the connection string is valid and has the necessary permissions for executing the intended queries.
  • Utilize Jinja templating in the SQL query to dynamically adjust the query based on workflow state.
  • Handle potential exceptions that may arise from database connectivity or query execution.