sql-agent
Provides read-only natural-language querying and SQL execution against a PostgreSQL database, with schema inspection, row-limited SELECTs, and golden-set answer evaluation.
Provides read-only natural-language querying and SQL execution against a SQLite database, with schema inspection, row-limited SELECTs, and golden-set answer evaluation.
sql-agent
An MCP server that answers questions about your SQL database, and measures whether the answers are right. SQLite and PostgreSQL, read-only.
uvx sql-agent-mcp --demoWhy it exists. Of the thirteen unambiguous questions DeepSeek-V3 got wrong on this project's golden set, eleven were valid SQL. No error, no NULL, no empty result: a query that runs, a number that is wrong, and prose that is sure of it. Reading the SQL does not catch that, and neither does asking the model. So this server ships the two things that do:
evaluateruns a golden set of your questions against your database and grades the agent by executing its SQL and comparing the rows with a hand-written reference. Not by reading the query, and not by asking a model.sql_was_executedseparates the SQL that actually ran from SQL the model only says it ran. Everyaskreturns both, with the rows and a trace of each step's latency and cost.
Measured, not claimed. On the bundled sample database, DeepSeek-V3 gets 17 of the 30 unambiguous cases right — 18/34 overall, $0.07 for the run. A second run scored 19/30, and four cases flipped between the two, so read that as "a bit over half", not as a decimal. The whole table is below, failure by failure.
Install
Nothing to install by hand: uvx fetches and
runs it. Point your MCP client at uvx sql-agent-mcp and give it a database.
Claude Code
claude mcp add sql-agent \
--env SQL_AGENT_DSN=sqlite:///./shop.db \
--env OPENAI_API_KEY=sk-your-key \
-- uvx sql-agent-mcpClaude Desktop — claude_desktop_config.json
{
"mcpServers": {
"sql-agent": {
"command": "uvx",
"args": ["sql-agent-mcp"],
"env": {
"SQL_AGENT_DSN": "sqlite:///./shop.db",
"OPENAI_API_KEY": "sk-your-key",
"OPENAI_BASE_URL": "https://api.deepinfra.com/v1/openai",
"SQL_AGENT_MODEL": "deepseek-ai/DeepSeek-V3"
}
}
}
}Cursor — .cursor/mcp.json in the project, or ~/.cursor/mcp.json
{
"mcpServers": {
"sql-agent": {
"command": "uvx",
"args": ["sql-agent-mcp"],
"env": {
"SQL_AGENT_DSN": "sqlite:///./shop.db",
"OPENAI_API_KEY": "sk-your-key",
"OPENAI_BASE_URL": "https://api.deepinfra.com/v1/openai",
"SQL_AGENT_MODEL": "deepseek-ai/DeepSeek-V3"
}
}
}
}PostgreSQL needs the driver, which is an extra. Use a postgresql:// DSN
and swap the command for:
uvx --from "sql-agent-mcp[postgres]" sql-agent-mcpIn the JSON configs that is
"args": ["--from", "sql-agent-mcp[postgres]", "sql-agent-mcp"]. Give it a
database role that only has SELECT — the GRANTs are below.
No database of your own? Drop SQL_AGENT_DSN and add --demo for the
bundled sample one. Its schema is deliberately awkward, and
the traps are listed below.
OPENAI_API_KEY is only needed by ask and evaluate, the two tools that
call a model; any OpenAI-compatible endpoint works. list_tables,
describe_table and run_sql need no key at all.
Prefer a plain install? pip install sql-agent-mcp puts sql-agent-mcp (the
server) and sql-agent (the same agent from the command line)
on your path.
The tools
Tool | What it does |
| Runs the whole agent loop. Returns the answer, the SQL that actually executed, the rows, and the trace. |
| Runs a golden set against this database. Returns accuracy, every failure with its reason, the tool path and the cost. |
| Every table with its row count. |
| Columns, types, foreign keys and three real rows. |
| One read-only |
ask reports final_sql and claimed_sql separately, and
sql_was_executed tells them apart. That distinction exists because of a real
bug: asked how many orders there were, the agent read the count off
list_tables and typed a SELECT COUNT(*) into its answer that it had never
run. A client must never quote unexecuted SQL to a user as evidence.
Related MCP server: NL-to-SQL MCP
What this project actually found
I built it expecting to demonstrate error recovery: the database is seeded with
traps, run_sql hands SQLite's error text back to the model, and there is a
test proving a failed call is followed by a successful one.
On eight questions, the recovery path never fired. Across two models the
measured recovery rate was 0%: both DeepSeek-V3 and Llama-3.1-8B call
describe_table before writing SQL, so neither ever hit no such column: total.
On thirty-four questions it fires — and it has never once saved the answer. Four runs recovered from a failed query, 12% of them, and all four still came back wrong. Three of those four then spent the rest of their step budget and never answered at all. So the machinery works, the harder questions do trip it, and tripping it is not where correctness comes from. Widening the golden set changed the claim; that is what the golden set is for.
What goes wrong is worse than an error. The agent writes valid SQL that returns a plausible wrong answer, and then describes it fluently.
The failure that makes the case
Asked for the top 5 customers by net spend, in the 8-case run, DeepSeek-V3 produced this:
JOIN order_items oi ON o.id = oi.order_id
LEFT JOIN refunds r ON o.id = r.order_idHanging both order_items and refunds off orders fans out the join: each
refund is counted once per line item in its order. SUM(r.amount_cents)
over-counts, and net spend is deflated for exactly the customers who bought the
most items.
reference | agent | |
1 | Joaquín Figueroa — 11,104.00 | Joaquín Figueroa — 11,104.00 |
2 | Isabella Lagos — 10,584.00 | Isabella Lagos — 10,584.00 |
3 | Paz Cabrera — 8,552.50 | Thiago Rojas — 8,012.00 |
4 | Dante Figueroa — 8,082.00 | Sofía Muñoz — 7,094.00 |
5 | Thiago Rojas — 8,012.00 | Paz Cabrera — 6,841.00 |
The top two are right. The prose was confident. No error, no NULL, no suspicious zero — just a number that is wrong by $1,711.50 and a customer who silently drops two places.
Nothing short of running the query and comparing rows catches this.
Llama-3.1-8B failed the same question differently: it filtered
status = 'completed' (dropping shipped orders, which nobody asked to exclude),
returned customer IDs instead of names, and used SUM(r.amount_cents) without
COALESCE, so every customer with no refunds evaluated to NULL and fell out of
the ranking entirely. Same loop, same prompt, a different wrong answer.
The golden set now has a labelled case for each of those three shapes —
join_fanout, missing_group_by, nulls_without_coalesce — because a failure
you have seen once and not written down is a failure you will ship again.
Which was the right call: on the 34-case run DeepSeek-V3 fans out the join
again, this time on items_and_refunds_per_order, and over-filters to
status = 'completed' on top_customers_net — the failure that had been
Llama's. The shapes recur across questions and across models. The specific
case they land on does not.
A real run
question: Who are the top 5 customers by how much they actually spent? …
[1] think 3747 ms 856+18 tok $0.0002
[2] list_tables 6 ms ok 6 tables
[3] think 5203 ms 1005+88 tok $0.0003
[4] describe_table 0 ms ok customers: 5 columns
[5] describe_table 0 ms ok orders: 5 columns
[6] describe_table 0 ms ok order_items: 5 columns
[7] describe_table 0 ms ok refunds: 5 columns
[8] think 45766 ms 2428+523 tok $0.0011
[9] run_sql 4 ms ok 5 rows
[10] think 30060 ms 3105+329 tok $0.0011
[11] finish 0 ms ok answered 11 steps · 7 tool calls · 0 recoveries · 84.8s · $0.0027That is the run from the table above — the one with the wrong answer. Eleven steps, no errors, under three tenths of a cent, and incorrect. This is why the trace alone is not enough and the grader has to execute.
(That trace is from the 8-case run, under the earlier system prompt. It is kept because it is the run the table above came from; the current numbers are further down.)
The database
The bundled sample database is shaped like a real operational schema rather than a tutorial one, so that guessing is punished:
Trap | What a guessing agent does | What it has to do |
|
| join |
Money is INTEGER cents | reports | divide by |
| joins to today's catalogue price | use the price actually paid |
| counts cancelled orders as revenue | filter them out |
| reports gross as net | subtract, without fanning out the join |
| joins it for no reason | ignore it |
A test asserts orders never grows a total column, because the day it does,
the trap becomes theatre. Seeding is deterministic, so the golden answers hold
across machines.
It is built only when you ask for it — --demo, SQL_AGENT_DEMO=1 or
--build-db. That used to be automatic whenever the path did not exist, which
meant a typo in a path produced a working agent confidently answering questions
about data the user had never seen.
Your own database
One connection string, in SQL_AGENT_DSN or --dsn:
SQL_AGENT_DSN=sqlite:///./shop.db
SQL_AGENT_DSN=postgresql://readonly:password@localhost:5432/shopA path with no scheme is read as SQLite. MySQL says so rather than failing
obscurely: engines live in sql_agent/adapters.py
behind one small interface — connect, list, describe, select — so adding one is
a subclass and a line in _ADAPTERS, with no change to the tools the agent
calls.
On PostgreSQL, give it a role that only has SELECT. The server already
opens every connection with default_transaction_read_only=on, runs each
statement in a READ ONLY transaction and sets a statement_timeout:
CREATE ROLE sql_agent LOGIN PASSWORD '…';
GRANT CONNECT ON DATABASE shop TO sql_agent;
GRANT USAGE ON SCHEMA public TO sql_agent;
GRANT SELECT ON ALL TABLES IN SCHEMA public TO sql_agent;Those three rails stop a mistake. The role is what stops everything else, and it does not depend on this code being correct.
One difference worth knowing: on PostgreSQL list_tables reports the planner's
row estimate, marked rows_estimated, instead of count(*) per table.
list_tables is meant to be the cheapest way to orient, and counting every row
of every table would blow the statement timeout on the agent's first call.
describe_table still returns three real rows on both engines.
How it works
START → think → (tool calls?) → act → think → … → ENDA LangGraph state machine with two nodes. think asks the model what to do
next; act runs it and writes the result back as an observation.
Tools never raise. A failing tool returns {"ok": false, "error": ...}. An
exception ends the run; a returned error is something the agent can act on.
describe_table returns sample rows, not just types. INTEGER does not
tell you a column holds cents. 18900 does.
The loop is bounded by SQL_AGENT_MAX_STEPS, enforced in the graph rather
than requested in the prompt. The failure mode of an unbounded agent is not a
wrong answer, it is a bill.
Two barriers, not one
The connection is read-only — mode=ro on SQLite, a READ ONLY transaction
with a timeout on PostgreSQL. That is the first barrier, and the one that holds
if everything above it is wrong.
The second is sql_agent/sqlguard.py, which parses
the statement with sqlglot in the dialect it is headed for and accepts exactly
one query: a SELECT, a set operation, or a parenthesised one, with no write,
ATTACH, PRAGMA, SET, COPY or row lock anywhere in the tree.
It used to be a regular expression over a list of forbidden words, which was wrong in both directions. It rejected valid work:
SELECT replace(name, 'a', 'b') FROM products -- the word REPLACE
SELECT * FROM logs WHERE body LIKE '%create%' -- the word CREATE
SELECT created_at FROM orders -- \b did not save it eitherand a word-list cannot tell where in a statement a word sits, so it had no
answer for a second statement after a semicolon, or for a write hidden in a
CTE — WITH d AS (DELETE FROM orders RETURNING id) SELECT * FROM d is a delete
that begins with the letters W-I-T-H, and PostgreSQL really runs it. Parsing
catches both. Its tests are half false positives and
half those.
A parser is not a security boundary either. pg_read_file, a hostile
function in a user's own schema, and anything else a SELECT can legally reach
are the role's problem, not the parser's.
Evaluation
python evals/run_eval.py --demo --json report.json
python evals/run_eval.py --dsn postgresql://… --golden my_questions.yamlThirty-four cases in evals/golden.yaml, each with a
reference query written by hand, executed to verify it, and labelled with
the traps it tests — twenty-six distinct ones, including join fan-out, a
missing GROUP BY, SUM over a LEFT JOIN with no COALESCE, and date
filters where the boundary is the whole question.
Grading compares result sets, not text. Not the prose, and not the SQL string either — two correct queries rarely look alike, so grading the text mostly measures style. The agent's final query and the reference both run against the same database.
Three rules, each of which cost a round of false failures to learn:
Row order is compared only when the question asked for one. Cases carry
ordered: truewhen the ranking is the answer.Extra columns are allowed. Asking for
name, spendand getting backid, name, gross, refunds, spendis cosmetic.A case with tied values at the cut is never graded on order, however much the question reads like a ranking. Two equally correct queries break a tie differently, and failing one of them measures the grader's
ORDER BY. Every ordered case was checked for ties by running it.
The first version of this harness had none of them and reported 3/8 on the
original eight cases. Two of
those failures were correct answers returned in a different row order, on
questions that never specified one, and a third was an ambiguous question —
"what share" got 0.1553 against a reference of 15.53, and both readings
are defensible. The real number was 6/8. A grader that can be wrong about the
agent needs its own tests.
That ambiguous question is now a case in its own right. Four cases are marked
ambiguous: true, each carrying the reading its reference encodes, and they
are reported apart from the headline accuracy: a question with two defensible
answers measures the question at least as much as the agent, and averaging it
in hides both.
Reported per run, alongside accuracy: recovery rate, average steps, cost per question, and the tool path — which tools in what order. An agent that reaches the right number in nine confused steps and one that does it in three are not the same agent, and only one of them is affordable.
Point --golden at your own file to grade the agent on your own questions
against your own database. The evaluate MCP tool takes the same path.
Current numbers
DeepSeek-V3 via DeepInfra, on the 34-case set, sample database, one run per
case. Full report: evals/report.json.
accuracy | 18/34 — 53% |
accuracy, unambiguous cases only | 17/30 — 57% |
ambiguous cases matching the reference reading | 1/4 |
recovery rate | 12% (4 runs), none of which produced a right answer |
ran out of step budget | 3/34 |
avg steps | 9.6 |
total cost | $0.0679 |
accuracy | 6/8 |
recovery rate | 0% |
avg steps | 8.8 |
total cost | $0.0136 |
Report: evals/report-8case.json. Not comparable
with the table above: the set is different and the system prompt has changed
since (it no longer asserts that money is in cents, which was a fact about
this sample database being told to an agent pointed at somebody else's).
Every failure, and why
The point of the set is this table, not the percentage.
Case | What it did | Trap |
| joined |
|
| summed |
|
| filtered |
|
| omitted the |
|
| averaged line items instead of order totals |
|
| right logic, right rows, never divided the cents by 100 |
|
| returned | — |
| same | — |
| returned the 30 matching customers instead of counting them |
|
| returned two counts and left the division to the reader |
|
| computed each reason's share by refund count instead of by amount |
|
| failed a query, recovered, ran out of steps without answering |
|
| same |
|
| same |
|
| gross over every order, cancelled included, refunds not subtracted | ambiguous |
| counted cancelled orders as loyalty | ambiguous |
Three things worth saying out loud about that table.
Eleven of the thirteen unambiguous failures are valid SQL. No error, no NULL, no empty result — a number that is wrong and prose that is sure of it. This is the case for executing the query and comparing rows, and nothing weaker catches any of them.
Two cases fail for returning an id where the question asked for a product. That is the grader making a judgment, and it is the same judgment it made of Llama-3.1-8B returning customer IDs instead of names. A foreign key is not an answer a person can read. Reasonable people could grade those two the other way; this set grades them as wrong and says so here rather than burying it.
Three cases spent the budget and never answered. SQL_AGENT_MAX_STEPS
counts model and tool steps, so a question that needs four describe_table
calls has already spent nine of its twelve before writing any SQL. All three
had executed a query by then, and this run found a bug in the reporting of
that: the step-budget exit was the one path that never recorded final_sql, so
all three were reported as having produced no SQL at all while their own step
list showed a successful run_sql. The trace now records the query and the
grader still fails the case, saying "stopped on the step budget without
answering" — an agent that never commits to an answer has not answered, and
crediting that query would be the same mistake as crediting SQL typed into
finish and never run. Whether the default budget should be higher was a real
question, so it was measured. It should
not.
One operational note: the run took 16 minutes of wall clock, 10 of which were a
single stall at the provider on items_and_refunds_per_order (614s for a
10-step run). That is the endpoint, not the agent.
A second run, with a 20-step budget
Same 34 cases, same model, SQL_AGENT_MAX_STEPS=20. Report:
evals/report-steps20.json.
12 steps | 20 steps | |
accuracy | 18/34 | 20/34 |
unambiguous only | 17/30 | 19/30 |
ran out of budget | 3 | 0 |
most steps any case used | 13 | 14 |
recoveries that ended in a right answer | 0 of 4 | 0 of 2 |
total cost | $0.0679 | $0.0680 |
The bigger budget rescued none of the three. All three finished this time, and all three finished wrong:
Case | With room to answer, it answered |
| the right logic, in cents — |
| in cents again, and with cancelled orders counted as spend |
| a join fan-out so thorough that refunds came out larger than revenue, and no share computed |
So at 12 steps those three runs said nothing, and at 20 they said something wrong with confidence. Of the two, saying nothing is the better failure. The default stays at 12, and nothing needed more than 14 anyway.
The two extra passes are noise, not budget. Four cases that never came
near the limit changed result between the runs: top_customers_net,
items_and_refunds_per_order and refund_rate went from wrong to right, and
monthly_revenue from right to wrong — by filtering status = 'completed',
the same over-filter again, on a third case. That is with temperature=0.
Seventeen cases passed both times and thirteen failed both times; the other
four are coin flips, which is what
the outside evaluation said about the 8-case
set too. One run per case is a sample, and the difference between 18 and 20 is
inside it.
Across both runs the recovery path fired six times and has still not produced a correct answer.
Evaluated from the outside
agent-evals runs this agent's own golden set three times per case and checks the trajectory, not just the answer. It found two bugs this harness could not:
The agent reported SQL it never executed. Asked how many orders there were, it read the count off
list_tablesand typed aSELECT COUNT(*)into its final answer. The outcome grader scored it correct, on fabricated evidence.final_sqlnow only ever holds SQL that actually ran; what the model claimed is kept separately asclaimed_sql.Malformed tool arguments crashed the run. Llama-3.1-8B sends
argumentsas a JSON array where the schema asks for an object; the parsed list reached.get()and the whole attempt died. Six of its twenty-four attempts were crashes scored as model failures. They now come back as a tool error the model can correct.
That evaluation also disagrees with the 8-case number: three runs per case put this agent at 4/8 strict, not 6/8. One of the passing cases was a coin flip.
From the command line
Python ≥ 3.11 and any OpenAI-compatible endpoint.
git clone https://github.com/Nachodusan/sql-agent
cd sql-agent
uv venv && uv pip install ".[dev,postgres]" # or: pip install ".[dev,postgres]"
cp .env.example .env # add your key and your DSN
python -m sql_agent.cli --build-db # generate the sample database
python -m sql_agent.cli --demo "how many orders came through each channel in Q1?"
python -m sql_agent.cli --dsn postgresql://… "top 5 customers by spend" --save--save writes the full trace to traces/<run-id>.json. There is no default
database: pass --dsn, --db or --demo, or set SQL_AGENT_DSN. Picking the
wrong database is a mistake worth catching before the first token is spent.
Editable installs (
pip install -e) rely on.pthfiles, which Python 3.15 no longer processes. The flat layout does not need one — running from the repository root works.
Tests
pytestAll offline, no network, no API keys, no services. The agent tests drive the
loop with a scripted model replaying fixed turns, and conftest.py strips
the model credentials out of the environment for every test, so a test that
forgets to inject a scripted model fails loudly instead of quietly billing
whoever ran it. (That guard exists because a smoke test picked up a real key
from a local .env and asked DeepSeek-V3 a question nobody meant to pay for.)
Testing against a live model tests the model; these test the loop, the statement guard, the adapters, the grader and the MCP server's tool contract.
The PostgreSQL adapter tests need PostgreSQL, so they are skipped unless you opt in with a throwaway database:
SQL_AGENT_TEST_PG_DSN=postgresql:///sql_agent_test pytestThey create and drop a schema of their own. A suite that needs a service is a suite that fails for the wrong reasons, which is why it is not the default.
Publishing
On PyPI as sql-agent-mcp and in the
official MCP registry as io.github.Nachodusan/sql-agent. The import package
is sql_agent; the commands are sql-agent-mcp and sql-agent.
server.json is the registry manifest, validated against the
published 2025-12-11 schema. Pushing a version tag runs
publish.yml, which publishes to PyPI
through Trusted Publishing and then to the registry through GitHub OIDC — no
stored token for either. RELEASING.md has the steps, and
CHANGELOG.md what changed.
The Dockerfile is for container hosts, which cannot speak
stdio: sql-agent-mcp --transport streamable-http serves on $PORT.
What this is not
Not a text-to-SQL benchmark entry. It is a working loop with honest instrumentation and a golden set that executes.
Not a substitute for a read-only database role. A read-only connection and a parser are two barriers against a mistake, not against an attacker.
Not a recovery demo, as it turns out. The recovery path is implemented and tested. It never fired on the 8-case set, fires on 12% of the 34-case set, and has not yet produced a single correct answer when it does. Reporting that is more useful than engineering a run that trips it.
Licence
MIT.
Available Tools
5 toolsaskAsk the database a questionA
Answer a question about the database in plain language. Returns the answer, the SQL that was actually executed, the rows it returned, and a trace of every step with its latency and cost. sql_was_executed is false when the agent answered without running a query; in that case final_sql is null and claimed_sql holds whatever SQL the model typed into its answer without running it.
Inputs: question (required). Returns: object
describe_tableDescribe a tableA
A table's columns, types, foreign keys and three real rows. Read this before writing SQL against a table you have not inspected: the sample rows are what reveal that an INTEGER column holds cents and that a TEXT column holds ISO dates.
Inputs: table (required). Returns: object
evaluateEvaluate the agent on a golden setA
Run a golden set of questions with hand-written reference SQL against this database and report accuracy, every failure with its reason, the tool path taken and the cost. Pass the path to a YAML file of cases; omit it to use the one bundled with the sample database. Each case runs the full agent loop, so this calls the model once per step of every case and is not free — use only to run a single case first.
Inputs: only, golden_path. Returns: object
list_tablesList tablesA
Every table in the database with its row count. On PostgreSQL the count is the planner's estimate, marked rows_estimated, because counting every row of every table to orient is not cheap.
Inputs: no named parameters. Returns: object
run_sqlRun a read-only queryA
Execute one read-only SELECT or WITH statement and return up to 50 rows. Anything else is refused: several statements, a write, a write inside a CTE, ATTACH, PRAGMA, SET, a row lock. When the database rejects the query you get its own error text back, which is usually enough to fix it.
Inputs: query (required). Returns: object
Tool Schema Changelog
Recent tool additions, removals, and schema changes observed during successful MCP inspections.
Loading tool schema changelog…
TDQS
Scored across 5 tools
Each tool occupies a clearly distinct niche: list_tables and describe_table differ in granularity (inventory vs. columns/sample rows), run_sql executes agent-authored SQL, ask handles natural-language questions, and evaluate runs a golden-set harness. The ask vs. run_sql boundary is explicitly clarified by the input type (plain language vs. SQL) and the returned sql_was_executed/final_sql fields.
Three tools follow a clean verb_noun pattern (list_tables, describe_table, run_sql), and all five are verb-first imperatives. However, ask and evaluate are bare verbs with implicit nouns, which is a minor deviation from the otherwise predictable scheme.
Five tools is tight and well-scoped for a read-only SQL agent: orient, inspect, execute, ask in natural language, and evaluate accuracy. No tool feels redundant or like filler, and nothing essential is obviously missing at this size.
The surface covers the full read-only lifecycle—discover tables, inspect schemas with sample rows, run SELECT/WITH queries, ask plain-language questions, and validate against golden cases. Minor gaps remain, such as no dedicated EXPLAIN/query-plan or schema-search tool, though agents can approximate both through run_sql against catalog tables.
Maintenance
Related MCP Connectors
MCP server providing access to the Scorecard API to evaluate and optimize LLM systems.
Hosted SQL Server MCP server for Claude, ChatGPT and Cursor, with each action switched per account.
Related MCP Servers
- FlicenseNot gradedqualityFmaintenanceA production-ready MCP server that transforms natural language into safe, executable SQL queries with multi-database support and intelligent schema analysis.1-
- FlicenseNot gradedqualityDmaintenanceMCP server enabling natural-language querying of SQLite databases via schema discovery, GraphRAG retrieval, and safely guarded read-only SQL execution.-
- AlicenseNot gradedqualityDmaintenanceEnables natural language querying of SQLite databases through a secure MCP server that writes, runs, and explains SQL with a three-layer read-only guarantee.MIT
- AlicenseNot gradedqualityDmaintenanceMCP server that translates natural-language questions into SQL, validates every query structurally, and executes approved read-only queries against a SQLite database, returning results and rejections.MIT