How to approve AI-generated SQL before it runs

Keep a human step between generating SQL and executing it: see the query first, run it only with an explicit click, and connect read-only so a mistake cannot change data. Here is how to set that up, and exactly what AI2SQL does at each step.

Updated 6 October 2026

Short answer: AI-generated SQL runs without approval when the same step that writes the query also executes it. To prevent that, separate the two: have the tool show the SQL and wait for an explicit Run, turn on tool-call approval in any AI app that can execute queries, and connect with a read-only database user so that whatever does run cannot change data.

Three controls that keep a human in the loop

1. Show the SQL, and run it only on an explicit click

The simplest approval step is a person reading the query before pressing Run. Prefer tools that put the generated SQL in front of you, let you edit it, and do nothing until you choose to execute it. Be careful with "auto-run" or "answer my question" modes on real data: they skip this step by design.

2. Use your AI app's tool approval

When an AI assistant such as Claude or ChatGPT can call a database tool, the assistant app decides whether to ask you first. Check its settings for connectors or tools and require confirmation for any tool that runs queries, at least until you trust the setup.

3. Connect read-only, with limits

Approval catches mistakes you notice; permissions catch the rest. Give the AI tool a database user with SELECT-only grants, ideally on a replica, and prefer tools that also reject non-read statements and cap rows and run time. See how to give an AI agent read-only database access.

What AI2SQL does at each step

In the web builder

Through the MCP server (Claude, ChatGPT, Cursor)

Setup steps for each assistant are on the AI2SQL MCP page. Connecting your own database is part of the Pro and Team plans; the Free plan includes 3 queries a day on a demo database.

A quick checklist

  1. Generate the SQL, then read it: tables, filters, joins and anything that looks like a write.
  2. Edit it if needed, and run it yourself only when it looks right.
  3. Connect AI tools with a read-only user, ideally against a replica.
  4. In AI assistants, require approval for tools that execute queries.
  5. For anything that changes data, copy the SQL into your usual change process instead of letting an AI tool run it.

Frequently asked

How can I stop AI-generated SQL from running without approval? +

Put a human step between generating SQL and executing it. Use a tool that shows the SQL and waits for you to click Run, turn on tool-call approval in your AI app if an agent can execute queries, and connect with a read-only database user so anything that does run cannot change data. In the AI2SQL web builder, SQL generated for your own connected database is shown first and runs only when you click Run.

Does AI2SQL run generated SQL automatically? +

Not on your own databases. In the web builder, generated SQL appears in the output panel and runs only when you click Run. The exception is the demo_shop sample database, which holds sample data: there a generated SELECT or WITH query runs right after it is generated so you can see results.

Can I edit AI-generated SQL before running it? +

Yes. In the AI2SQL web builder, the Edit button next to Run (shown on wider screens) lets you change the generated SQL. Run executes the SQL as it is shown in the output panel.

What happens if the AI writes an UPDATE, DELETE or DROP? +

When you click Run on your own database, the AI2SQL web builder refuses statements that do not start with SELECT, WITH, SHOW, EXPLAIN or DESCRIBE, and refuses more than one statement at a time. Through the MCP server, run_query accepts a single SELECT or WITH query only; writes, DDL and multiple statements are rejected before they reach the database.

Do Claude or ChatGPT ask me before running a query? +

That is decided by the AI app, not by AI2SQL. Claude and ChatGPT have their own settings for when to ask before using a connector or tool, so check your app's settings. AI2SQL labels its tools as read-only with MCP tool annotations, which the MCP specification defines as hints for clients.

Review the SQL, then run it

In the AI2SQL builder, SQL for your own database is shown first and runs only when you click Run, after a read-only check. Connecting your own database is part of Pro, $19/month after a 7-day trial.

Start a 7-day trial →

A credit card is required to start the trial. You are charged only if you keep the plan after 7 days; cancel anytime before then. The Free plan includes 3 queries a day on a demo database.

Related guides