pg_execute_sql
Execute SQL statements on PostgreSQL databases with parameter support, transaction handling, and timeout control for data operations and schema management.
Instructions
Execute arbitrary SQL statements - sql="ANY_VALID_SQL" with optional parameters and transaction support. Examples: sql="CREATE INDEX ...", sql="WITH complex_cte AS (...) SELECT ...", transactional=true
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| connectionString | No | PostgreSQL connection string (optional) | |
| sql | Yes | SQL statement to execute (can be any valid PostgreSQL SQL) | |
| parameters | No | Parameter values for prepared statement placeholders ($1, $2, etc.) | |
| expectRows | No | Whether to expect rows back (false for statements like CREATE, DROP, etc.) | |
| timeout | No | Query timeout in milliseconds | |
| transactional | No | Whether to wrap in a transaction |