Skip to content
NarraNexus
All templates
developmentdata

SQL Assistant

by Community contributor · MIT

Local Build assumes a NarraNexus instance running at localhost:5173 — start it first with bash run.sh.

Desktop App requires the NarraNexus DMG installed to /Applications/ (and opened at least once so macOS registers the narranexus:// handler).

SQL Assistant turns natural-language questions into optimized SQL queries. Ask "show me users who signed up last week but never logged in" and it returns the LEFT JOIN plus a paragraph explaining how the query works and which index will make it fast. Beyond translation, the agent debugs slow queries: paste an EXPLAIN ANALYZE plan and it identifies full table scans, missing indexes, and subquery rewrites — typical wins take a 12-second query under 200ms. It also documents schemas, suggests fixes for SQL errors, and explains execution plans in simple terms. It ships the **model-cost-compare** skill so you can decide whether a heavy query-generation session is worth the LLM cost — compare token prices across major models and pick the right one. Guardrail: it warns before any DELETE or UPDATE without a WHERE clause, and never executes destructive statements itself — you copy the SQL out and run it.

How to use it

Talk to SQL Assistant. Three modes: 1. Plain-English → SQL > "From `orders`, `users`, and `refunds`, give me the top 10 net-revenue users last quarter, excluding any with refund rate over 50%." It outputs the SQL + a quick explanation and any index recommendations. 2. Optimize a slow query > Paste your query or EXPLAIN ANALYZE plan and say "this takes 12 seconds, help me optimize." 3. Debug an error > Paste the error and the query — it diagnoses and suggests a fix. Ask it to use model-cost-compare ("compare model costs for this workload") when planning a heavy session and want the cheapest capable model. Works against PostgreSQL, MySQL, and SQLite syntax. The agent never runs destructive statements — you copy the SQL out and execute yourself.

Agents in this template

  • SQL Assistant

How to install (manual)

  1. Click Download .nxbundle above.
  2. Open your NarraNexus app and go to Settings → Import bundle.
  3. Drag the downloaded file in, review the preflight, confirm.

One-click install (a deep link that imports directly into your cloud or desktop NarraNexus) is the next milestone.