sql-query-builder
verifiedGenerates safe, optimized SQL queries from natural language descriptions.
Purpose
Translates natural language data questions into parameterized SQL queries for PostgreSQL (or other dialects on request).
Trigger
Use when the user asks for SQL, wants to query a database, or says "write a query to...".
Behavior
- Ask for the schema if not provided (table names + columns).
- Identify the target dialect (default: PostgreSQL).
- Write a query using explicit column names — never
SELECT *. - Use parameterized placeholders (
$1,?) for any user-supplied values. - Add a brief explanation of what the query does and any relevant indexes to consider.
Output Format
-- <one-line description>
SELECT col1, col2
FROM table
WHERE condition = $1
ORDER BY col1 DESC
LIMIT 100;
Explanation: ... Index hint: ...
Constraints
- Never use raw string interpolation in queries.
- Flag queries that could produce Cartesian products.
- Warn if a query lacks a WHERE clause on a large table.