Natural language to SQL inside Google Sheets

FeatureMay 15, 2026 · 7 min read

You shouldn't need to remember JOIN syntax to ask your database for the top 10 customers by total order amount. You shouldn't need to think about PartiQL constraints to query DynamoDB. You shouldn't need to memorize PostgREST's filter syntax to slice a Supabase table.

gptsheet's Ask SQL feature does the translation. Type the question in plain English; the formula generates the right query for your DB; you click Run; the rows land in the sheet.

How it works

  1. You connect a DB connector — MySQL, MS SQL, Postgres, Supabase, or DynamoDB — via the sidebar (browser → DB, no proxy).
  2. Expand the connector card. Below "Browse tables" you see Ask.
  3. Type a question: "top 10 customers by total order amount in the last 30 days".
  4. Hit Generate. gptsheet fetches the live schema (tables + columns) and sends it to your LLM provider along with the question.
  5. The generated SQL appears in an editable code box. Review it.
  6. Hit Run. The query executes; rows write into the active cell; the query is saved as an Import you can rerun later.

Per-database behavior

DatabaseGeneratesSchema fetched from
MySQLMySQL SELECTINFORMATION_SCHEMA.COLUMNS
MS SQL ServerT-SQL SELECT (TOP 1000)INFORMATION_SCHEMA.COLUMNS
Postgres (PostgREST)PostgREST URL fragmentOpenAPI / spec
SupabasePostgREST URL fragmentOpenAPI / spec
DynamoDBPartiQL SELECTListTables + DescribeTable

Each database has its own dialect quirks; the system prompt is tuned per-database to respect them (no JOINs in PartiQL, no SQL JOINs in PostgREST — use embedded resources, etc.).

Example: Postgres / Supabase

Schema: customers (id, email, plan, created_at), orders (id, customer_id, total, created_at).

Question: "top 10 customers by total order amount this month".

Generated PostgREST URL:

customers?select=email,plan,orders(total)&orders.created_at=gte.2026-05-01&order=orders.total.desc&limit=10

No JOIN keyword. PostgREST uses embedded resources for joins. The LLM knows this — gptsheet's prompt teaches it.

Example: DynamoDB

Tables: Orders (OrderId [HASH], CreatedAt [RANGE]), Users (UserId [HASH]).

Question: "orders for OrderId 'O-12345'".

Generated PartiQL:

SELECT * FROM "Orders" WHERE OrderId = 'O-12345'

PartiQL constraints respected: no JOINs, no GROUP BY, partition-key filter for indexed access. The schema fetch includes [HASH] / [RANGE] hints so the LLM picks efficient filters.

Safety

Generated SQL is shown before running. You can edit it. If the generated statement contains INSERT / UPDATE / DELETE / DROP / ALTER / TRUNCATE / CREATE / GRANT / REVOKE, a confirmation prompt asks you to approve. The system prompt explicitly forbids these, but the confirmation is a second line of defense.

Saved as Imports

Every Ask SQL run is saved as an Import you can rerun. Useful patterns:

When this isn't enough

Cost

Each generation call: ~1,500 input tokens (schema + question) + ~150 output tokens (SQL). At Gemini Flash list prices: ~$0.0001 per query. Effectively free.

The cost you actually care about is the SQL execution against your own DB — that's free if you self-host, or normal Stripe/Heroku/RDS pricing if you don't.

Try Ask SQL on your DB

DB connectors are in the Max tier — $299 lifetime. Includes 5 databases + the SQL Builder.

Get gptsheet Max