Skip to content

PostgreSQL

The PostgreSQL block allows you to connect to PostgreSQL databases and execute queries directly within your runbook.

Connection

Configure your PostgreSQL connection using a standard PostgreSQL connection URI:

postgresql://username:password@host:port/database

URI Only

Currently, PostgreSQL blocks only support connection URI format. Individual connection parameters (host, port, etc.) are not supported at this time.

Query Execution

Write and execute SQL queries against your PostgreSQL database. Results are displayed in a table format within the runbook. PostgreSQL supports advanced SQL features like:

  • Common Table Expressions (CTEs)
  • Window functions
  • JSON/JSONB operations
  • Array operations
  • Full-text search

Template Usage

All input fields are first rendered by the templating system, allowing you to use variables in your queries and connection parameters.

SELECT * FROM users WHERE created_at > '{{var.start_date}}' 
AND department = '{{var.department}}';

Use template variables to create flexible queries that adapt based on runbook inputs or previous block outputs.

Security

Consider using secrets for sensitive connection parameters like passwords to avoid storing credentials in plain text.

Security Best Practices

  • Never hardcode credentials in your runbooks
  • Use environment variables or the secrets system
  • Consider using read-only database users for monitoring queries
  • Be cautious with queries that modify data (INSERT, UPDATE, DELETE)