product··5 min read·WoWSQL Team

AI SQL Assistant: Write Postgres Queries in Plain English

How to use an AI SQL assistant safely on Postgres: where text-to-SQL goes wrong, a review checklist, WoWSQL's MERA editor and read-only MCP setup.

An AI SQL assistant turns a plain-English question into a SQL query you can run, and the safe way to use one is to treat its output as a draft you read before it touches real data. WoWSQL gives you two options for PostgreSQL: MERA, an assistant built into the dashboard SQL editor, and a hosted MCP server (https://mcp.wowsql.com/mcp) that lets Claude, Cursor, ChatGPT and other AI clients inspect tables and run SQL on a project you choose.

This guide explains where text-to-SQL goes wrong (with a worked example), a review routine that catches most mistakes, and how to set up each WoWSQL option with as little access as possible. It also covers where competing MCP servers are stricter than ours.

Key facts

  • MERA: WoWSQL's AI SQL assistant, inside the dashboard SQL editor of each project. You describe what you want and it writes PostgreSQL for you to review, edit and run (MERA announcement).
  • Where MERA runs: the AI and MCP policy says MERA uses Amazon Bedrock (with Gemma), and the sub-processors page lists "AWS regions Bedrock uses for that feature". Do not paste card numbers, government IDs or secrets into it.
  • MCP server: https://mcp.wowsql.com/mcp, sign-in with OAuth and PKCE, scoped to the project you pick. Optional URL parameters: project_ref, read_only=true and features=account,database,docs (MCP overview).
  • MCP tools today: list_projects, get_project, list_tables, execute_sql and search_docs. There are no storage tools (MCP reference).
  • Limits: 100 MCP requests per minute on Pro and 250 on Scale (pricing, 27 November 2026). Plans: Free $0, Pro $25/month, Scale $99/month.
  • Source: the MCP server code is public at github.com/WoWSQL/MCP-Server under the Elastic License 2.0, which is source-available rather than an OSI open-source licence.

What an AI SQL assistant does

Text-to-SQL tools take three inputs: your question, a description of your schema (table and column names, sometimes types and keys), and optionally some example rows. A language model then writes a query. It does not know your business rules, which column is the "real" revenue number, or whether an orders table is soft-deleted. It only knows what the schema and your prompt tell it.

That makes assistants very good at the boring 80%: boilerplate SELECT statements, GROUP BY and window functions you half remember, CREATE TABLE drafts, index suggestions and Row Level Security policies. They are weakest on questions that depend on meaning rather than syntax.

Where text-to-SQL goes wrong

These are the failures that matter in practice, roughly in order of how often they cost people money or data.

1. Join fan-out gives plausible, wrong totals

Ask for "revenue per customer" and an assistant may join orders to order_items as well, because items look relevant. Each order row is then repeated once per item, and sum(orders.total) counts it several times. The query runs, the numbers look reasonable, and they are wrong.

On a tiny test dataset (customer Asha has two orders worth 100.00 and 50.00; the first order has three items), this query:

select c.name, sum(o.total) as revenue
from customers c
join orders o on o.customer_id = c.id
join order_items i on i.order_id = o.id
group by c.name;

returns 350.00 for Asha. The correct figure is 150.00, which you get by dropping the unneeded join:

select c.name, sum(o.total) as revenue
from customers c
join orders o on o.customer_id = c.id
group by c.name;

We ran both queries against a local Postgres-compatible engine to confirm the numbers. The lesson: always compare an AI-written total against a number you already trust.

2. Invented or wrong columns and meanings

If the schema is incomplete, the model guesses a column such as status = 'paid' that does not exist, or uses created_at when you meant the payment date. Postgres will often error on a missing column, which is the good case. The bad case is a real column with a different meaning than the model assumed.

3. Time zones and date boundaries

"Last month" or "today" depends on a time zone. A timestamptz compared with a date literal uses the session time zone, so an Indian business can silently lose or gain a day of sales. Say the zone in your prompt (for example, Asia/Kolkata) and check the boundaries.

4. Destructive statements

DELETE without a WHERE, UPDATE on the wrong table, DROP and TRUNCATE are one confident paragraph away from a bad day. This is the main reason to review before you run, and to give an AI client the minimum access it needs.

5. Slow queries that look fine

A model will happily write a query that scans a large table. It runs instantly on your 200-row dev data and then times out in production. Ask for an EXPLAIN and check for sequential scans on big tables.

6. Ignoring who is allowed to see what

An assistant that connects with a powerful role can read rows your app's users should never see. Row Level Security protects data when a request comes in as a user; it does not stop an admin-level connection from reading everything. See What is Row Level Security? for how that boundary works.

A review routine that catches most mistakes

Use this every time, whichever assistant you use:

  1. Give it the schema and the grain. Name the tables, the join keys and what one row means ("one row per order, not per item").
  2. Ask one question at a time. "Monthly revenue by plan for the last 6 months in Asia/Kolkata" beats "analyse my business".
  3. Read the SQL before running it. Check every JOIN, every WHERE, and the time range.
  4. Ask for the plan. Run EXPLAIN first. If it scans a large table without a filter, add an index or narrow the question.
  5. Run reads first. Use a read-only connection or a SELECT with LIMIT 100 before anything else.
  6. Wrap writes in a transaction. Run BEGIN;, the statement, a check SELECT, then ROLLBACK; (or COMMIT; when the counts are right). We confirmed on a test database that a DELETE inside a transaction is undone by ROLLBACK.
  7. Reconcile one number. Compare the result with a figure you already know, such as yesterday's order count.
  8. Keep an export. Free projects have no platform backups, and Pro and Scale keep daily backups for 7 days; this is not point-in-time recovery (backups policy). Export before any bulk change.

Option 1: MERA in the WoWSQL SQL editor

MERA lives in the dashboard, so there is nothing to install and no AI client to configure. To use it:

  1. Create a free project and open it.
  2. Open SQL Editor.
  3. Ask MERA a question in plain English, for example: "Top 10 products by revenue this month with customer count", "Add an index on email for the users table" or "Add RLS so users can only read their own profile row".
  4. Read the SQL it writes. Edit it. Run it only when you agree with it.

MERA is the right choice when you are already in the database UI, you want help writing or learning SQL, and you do not need an external AI client. Its limits are also its design: it works inside WoWSQL, so it will not look at your codebase or your other tools.

A privacy note worth knowing: per the AI and MCP policy, prompts and the context sent to Bedrock are processed by AWS to return an answer, and WoWSQL says it does not scan your entire database for a model unless an action you authorised does that. If your compliance review depends on where that processing happens, ask WoWSQL directly, because the sub-processors page says only "AWS regions Bedrock uses for that feature".

Option 2: AI clients through the WoWSQL MCP server

The Model Context Protocol (MCP) lets an AI client such as Claude, Cursor or VS Code call tools on a server. The WoWSQL MCP server is hosted at https://mcp.wowsql.com/mcp. Clients connect with OAuth in the browser; there are no long-lived database passwords to paste into a config file, and WoWSQL says it does not send database passwords to AI vendors.

A basic Cursor configuration from the Cursor setup page:

{
  "mcpServers": {
    "wowsql": {
      "type": "http",
      "url": "https://mcp.wowsql.com/mcp"
    }
  }
}

For anything touching real data, narrow it down with URL parameters from the MCP overview:

https://mcp.wowsql.com/mcp?project_ref=YOUR_PROJECT_SLUG&read_only=true&features=database,docs
  • project_ref pins the connection to one project and hides the account tools.
  • read_only=true rejects mutating SQL in execute_sql.
  • features=database,docs registers only the database and documentation tools.

Setup pages also exist for Claude, VS Code and other clients. For step-by-step walkthroughs see Connect Claude to your Postgres database with MCP, Cursor AI database setup and Postgres MCP server: local vs hosted options.

An honest note on read_only=true

Read the source before you rely on it. In the public repository, WoWSQL's read-only mode is a text check: it rejects a query if the upper-cased text contains patterns such as INSERT , UPDATE , DELETE , DROP , CREATE , ALTER , TRUNCATE , GRANT or REVOKE (checked 27 November 2026). That is a useful guardrail against an assistant's accidental write. It is not the same as running the query under a database role that cannot write, and it does not list every statement type that can change data or have side effects. Treat it as one layer: also keep client-side tool approval on, scope to a single project, and point assistants at a test project or a copy when you can.

Other things to know about the MCP route:

  • Results leave WoWSQL. Whatever rows and schema a tool returns go to the AI client, whose own privacy terms apply. ChatGPT, Claude and Cursor are not WoWSQL sub-processors (AI and MCP policy).
  • Prompt injection is real. Text stored in your tables can contain instructions aimed at the model. The MCP reference tells you to treat tool output as data and keep manual approval on for production.
  • Logs. MCP API logs are kept for up to 90 days (privacy policy).
  • Rate limits. 100 MCP requests per minute on Pro, 250 on Scale. The pricing page shows no per-minute figure for Free.

How the options compare

WoWSQL MERA WoWSQL MCP Supabase MCP Neon MCP
Where you use it Dashboard SQL editor Any MCP client (Claude, Cursor, VS Code, others) Any MCP client Any MCP client
Read-only switch Review SQL yourself before running read_only=true (text-pattern check, see above) read_only=true executes queries as a read-only Postgres user (Supabase docs, 27 Nov 2026) readonly=true or a read-only OAuth scope (Neon docs)
Project scoping Runs in the project you opened project_ref project_ref projectId
Schema-change safety None beyond your review None beyond your review Branching tools, experimental and on paid plans (AgentAtlas, 23 Oct 2026) Migrations tested on a temporary branch first (same source)
Vendor's own advice on production Do not paste secrets Keep approvals on; scope to one project Connect to production only when needed, scoped and read-only Development and testing only, not production

Where competitors are better: Supabase's read-only mode is enforced by the database role rather than by text matching, and both Supabase and Neon offer branch-based workflows that let an assistant try a schema change away from your live data. WoWSQL's strengths here are simplicity (an assistant inside the SQL editor with no setup), a flat price ($0, $25 or $99 per month, with 100 or 250 MCP requests per minute on paid plans), and a hosted MCP endpoint scoped to one project in a single URL. Neon's own documentation advises MCP for development and testing rather than production, which is a sensible default for any vendor.

Which should you use?

  • Learning SQL or drafting queries while you build: MERA.
  • Asking questions from your editor or chat with schema and docs in context: WoWSQL MCP, scoped to one project with read_only=true, on a test project first.
  • A bulk data change: write it yourself or with an assistant, but run it in a transaction, check the counts, and export first.
  • Anything an app's end users trigger: do not give them an AI SQL box. Use the auto-generated REST API with Row Level Security instead.

Related guides

FAQ

What is the best AI SQL assistant for Postgres?

It depends on where you work. If you want help inside a database UI, WoWSQL's MERA is built into the project SQL editor. If you want an AI client such as Claude or Cursor to see your schema, WoWSQL, Supabase and Neon all run hosted MCP servers with read-only options. Whichever you pick, read every query before running it and compare totals with a figure you already trust.

Can ChatGPT or Claude write SQL for my database?

Yes. Paste your schema and a clear question and either will draft a query. For live access, connect them through an MCP server so they can list tables and run queries, scoped to one project and read-only. Do not give a general-purpose chatbot a production connection string.

Is it safe to let AI run SQL on my production database?

Not by default. Models can write plausible but wrong joins and destructive statements. Use a test project or a copy, read-only access, tool-call approval in your client and a transaction with a rollback for writes, and keep your own export. WoWSQL's read_only=true is a text-pattern guardrail, so it should not be your only protection.

What is MERA in WoWSQL?

MERA is WoWSQL's AI SQL assistant in the dashboard SQL editor. You describe a query, table or policy in plain English and it writes PostgreSQL for you to review and run. According to WoWSQL's legal pages, it runs on Amazon Bedrock, and prompts plus the context sent to it are processed by AWS.

How do I connect Cursor or Claude to WoWSQL?

Add https://mcp.wowsql.com/mcp as an HTTP MCP server in your client and complete the OAuth sign-in in the browser. For safety, append ?project_ref=YOUR_PROJECT_SLUG&read_only=true&features=database,docs. Client-specific instructions are in the WoWSQL docs under MCP.

Why do AI-written SQL totals come out wrong?

The most common cause is join fan-out: an extra join repeats rows, so sums are counted several times. Others are guessed columns, time-zone boundaries and a different meaning of "revenue" than yours. Check the grain of each table, add the time zone to your prompt and reconcile against a known number.

Does WoWSQL send my data to AI companies?

Only when you use the AI features. MERA prompts and context go to Amazon Bedrock. With MCP, the schema and query results a tool returns go to the AI client you connected, under that company's terms. WoWSQL says it does not send database passwords to AI vendors and does not train public AI models on your databases.

Create a free WoWSQL project · Pricing · MCP docs