execute_query_read_only
Execute read-only SQL queries on Trino clusters, with optional output to file to prevent AI hallucination.
Instructions
Execute a read-only SQL query and return the results.
This tool is designed for read-only queries (SELECT, SHOW, DESCRIBE, EXPLAIN, etc.). It validates that the query is read-only before execution.
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 (must be read-only) 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 (read-only) | |
| 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 |