query
Turn natural-language questions into executed SQL queries against a database, returning results, row counts, and self-correcting errors while exploring the schema.
Instructions
Ask the database a natural-language question.
The agent explores the schema, writes SQL, executes it, and self-corrects on errors before returning. Read-only — only SELECT-style statements.
Args:
question: The natural-language question, e.g. "top 5 customers by revenue".
max_rows: Cap on rows returned in data. Defaults to 100.
Returns:
dict with:
sql: the final verified SQL
data: list of row dicts (capped at max_rows)
error: error message if execution failed, else None
row_count: number of rows in data
tool_calls_made: how many SQL calls the agent made while exploring
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| max_rows | No | ||
| question | Yes |