execute_query_to_file
Writes read-only SQL query results directly to a file at a chosen path. Save output as CSV or TSV without overwriting existing files.
Instructions
Writes read-only query results to a file at a path you choose.
Use when the result needs to land at a specific path -- to share or persist.
Format follows the extension: `.csv` writes CSV (NULL = empty field);
anything else writes TSV (same as execute_query: tab-delimited, NULL = `\N`).
Parameters:
- sql: read-only SQL (SELECT, SHOW, DESCRIBE, WITH)
- file_path: output path (absolute recommended; end with `.csv` for CSV,
else `.tsv` is used/appended)
- database: optional database context
- schema: optional schema context
- timeout_seconds: query timeout (default 300, max 3600)
Requires a populated schema cache. Will not overwrite an existing file.
Example: execute_query_to_file("SELECT * FROM t", "/tmp/export.csv")
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| sql | Yes | ||
| file_path | Yes | ||
| database | No | ||
| schema | No | ||
| timeout_seconds | No |