Overview
The PostgreSQL tool allows you to run SQL queries on a PostgreSQL database.Key Features
POSTGRES_RUN_QUERY- Run a SQL query on a PostgreSQL database. Supports SELECT, INSERT, UPDATE, DELETE, and other SQL statements.
- Inputs:
connection(a PostgreSQL connection secret) andquery(the SQL to run). - Retrieve results in a structured format (columns and rows).
Authentication
Create aPOSTGRES secret with your connection details and pass it as the connection input:
- Host: Hostname of the PostgreSQL server (required).
- Port: Port number. Defaults to
5432if omitted. - Database: Name of the database to connect to.
- User: Username to connect with.
- Password: Password for the user.
- SSL: Whether to use SSL. Enabled by default; set to
false(ordisable) to turn it off. The legacysslmodefield is also accepted.
SSL behavior
SSL is enabled by default and server certificates are not strictly verified. If the initial SSL connection fails and SSL was not explicitly disabled, the tool automatically retries without SSL (the server may not support it).Usage Examples
Example: Run PostgreSQL Query
Example: Query and Summarize with an LLM
Notes
- Timeouts: The connection attempt times out after 10 seconds, and each statement times out after 30 seconds.
- Not read-only: Write statements (INSERT, UPDATE, DELETE, DDL) are executed as-is. Use a database user with appropriately scoped privileges.
- Result serialization: Non-primitive values are converted to strings — dates become ISO 8601 strings, binary (
bytea) values become hex strings, and JSON/array/object values are serialized as JSON strings. - Non-row-returning statements: Queries that return no result set (e.g., plain
INSERTwithoutRETURNING) return emptycolumnsandrows.