execute_query
Execute SQL queries on Trino clusters. Optionally write results to a JSON or CSV file to prevent AI hallucination and enable downstream processing.
Instructions
Execute a SQL query and return the results.
This tool can execute any SQL query including write operations (INSERT, UPDATE, DELETE, etc.). By default, write operations are disabled for security. Set ALLOW_WRITE_QUERIES=true to enable.
When output_file is provided, results are written directly to disk and only a confirmation message is returned. This prevents raw data from passing through the AI, avoiding hallucination when processing large result sets. The output format (JSON or CSV) is derived from the file extension.
Args: query: The SQL query to execute output_file: File path to write results to. Extension determines format (.csv → CSV, .json or others → JSON). Results are NOT returned to the AI, enabling reliable downstream processing.
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| query | Yes | The SQL query to execute | |
| output_file | No | File path to write results to. Format is derived from the file extension: '.csv' for CSV, '.json' (or others) for JSON. When set, results are written directly to disk and are NOT returned to the AI, preventing hallucinated values and enabling subsequent processing by other tools. |
Output Schema
| Name | Required | Description | Default |
|---|---|---|---|
| result | Yes |