Postgres Block
Execute SQL queries on a PostgreSQL database
The Postgres block enables users to execute SQL queries on a PostgreSQL database within a Scout workflow. It facilitates database interaction by allowing users to specify a connection string and SQL query, with support for Jinja templating to dynamically construct queries based on workflow state.
Configuration (Required)
The connection string used to connect to the PostgreSQL database. Ensure this string is correctly formatted and has the necessary permissions to access the database.
The SQL query to execute against the database, supporting dynamic construction using Jinja templating. Use this feature to insert values from the workflow state into your query.
Outputs
The output of the Postgres block is a list of dictionaries representing the rows returned by the SQL query, with column names as keys. Additionally, the block provides details such as the response format and the elapsed time in milliseconds for executing the query.
Usage Context
Use this block to perform read operations on a PostgreSQL database, such as retrieving data for further processing in the workflow.
Best Practices
- Ensure the connection string is correctly formatted and has the necessary permissions.
- Use Jinja templating in the SQL query to dynamically insert values from the workflow state.
- Handle exceptions gracefully to manage database connectivity issues or query errors.