run_sql
Execute a SQL query against a fresh ephemeral in-memory database built from your schema (and optional seed rows). Returns real rows (max 500, truncation flagged), column names+types, row_count, and dialect notes. Errors come back as structured JSON with type/position/suggestion — a failed query is a useful answer, not a failure of this tool. Example: schema "CREATE TABLE t(id INTEGER, name TEXT);", query "SELECT name FROM t WHERE id=1", seed {"t":[{"id":1,"name":"ada"}]} → rows [["ada"]].
Parameters
| schema | string | required | DDL statements (CREATE TABLE ...; multiple statements allowed). |
| query | string | required | ONE SQL statement to execute. Stacked statements are rejected. |
| seed | object | optional | Optional seed rows: {"table_name": [{"col": value, ...}, ...]}. Max 10MB total. |
| engine | string | optional | Engine. Server-side supports 'sqlite' (default). 'duckdb' runs in the browser demo at sqlai.dev only. |
Raw schema
{
"type": "object",
"properties": {
"schema": {
"type": "string",
"description": "DDL statements (CREATE TABLE ...; multiple statements allowed)."
},
"query": {
"type": "string",
"description": "ONE SQL statement to execute. Stacked statements are rejected."
},
"seed": {
"type": "object",
"additionalProperties": {
"type": "array",
"items": {
"type": "object",
"additionalProperties": {}
}
},
"description": "Optional seed rows: {\"table_name\": [{\"col\": value, ...}, ...]}. Max 10MB total."
},
"engine": {
"type": "string",
"enum": [
"sqlite",
"duckdb"
],
"description": "Engine. Server-side supports 'sqlite' (default). 'duckdb' runs in the browser demo at sqlai.dev only."
}
},
"required": [
"schema",
"query"
],
"additionalProperties": false,
"$schema": "http://json-schema.org/draft-07/schema#"
}