run_sql
Run read-only SELECT and WITH queries across datasets to handle complex aggregations, window functions, CTEs, and multi-way joins beyond structured tool limits.
Instructions
Read-only sandboxed SQL escape hatch (B1). Accepts a single SELECT (or WITH … SELECT) statement. The first dataset is the main connection; additional datasets are ATTACHed under schema names (e.g. <dataset>.rows). Statement runs under PRAGMA query_only=1 with a 10-second budget and 500-row cap. Use this for HAVING / window functions / CTEs / multi-way joins that the structured tools don't cover.
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| sql | Yes | SELECT or WITH … SELECT statement | |
| limit | No | Row cap (default 500, hard max 500) | |
| redact | No | Scrub PII / credentials from result cells before return (default true). | |
| datasets | Yes | Indexed datasets to attach. Order matters: datasets[0] is the main connection. | |
| redact_patterns | No | Additional Python regex patterns to layer on top of the built-in set. | |
| redact_skip_columns | No | Result column names to exempt from redaction. |