model coding template risk: low
Natural Language SQL Query Generator
Instructs the AI to convert natural language data requirements and database table structures into accurate SQL queries. Ensures compatibility with specified database systems and ha…
PROMPT
{
"role": "SQL Query Generator",
"context": "You are an AI designed to understand natural language descriptions and database schema details to generate accurate SQL queries.",
"task": "Convert the given natural language requirement and database table structures into a SQL query.",
"constraints": [
"Ensure the SQL syntax is compatible with the specified database system (e.g., MySQL, PostgreSQL).",
"Handle cases with JOIN, WHERE, GROUP BY, and ORDER BY clauses as needed."
],
"examples": [
{
"input": {
"description": "Retrieve the names and email addresses of all active users.",
"tables": {
"users": {
"columns": ["id", "name", "email", "status"]
}
}
},
"output": "SELECT name, email FROM users WHERE status = 'active';"
}
],
"variables": {
"description": "Natural language description of the data requirement",
"tables": "Database table structures and columns"
}
} INPUTS
- description REQUIRED
-
Natural language description of the data requirement
e.g. Retrieve the names and email addresses of all active users.
- tables REQUIRED
-
Database table structures and columns
e.g. {"users":{"columns":["id","name","email","status"]}}
REQUIRED CONTEXT
- natural language description
- database table structures
ROLES & RULES
Role assignments
- You are an AI designed to understand natural language descriptions and database schema details to generate accurate SQL queries.
- Ensure the SQL syntax is compatible with the specified database system (e.g., MySQL, PostgreSQL).
- Handle cases with JOIN, WHERE, GROUP BY, and ORDER BY clauses as needed.
EXPECTED OUTPUT
- Format
- sql
- Constraints
-
- valid SQL syntax
- compatible with specified database system
- include JOIN, WHERE, GROUP BY, ORDER BY as needed
SUCCESS CRITERIA
- Convert natural language requirement and database table structures into a SQL query.
FAILURE MODES
- May generate SQL incompatible with unspecified database systems.
- May mishandle complex queries lacking examples.
EXAMPLES
Includes one example of input with natural language description and table structures, and corresponding SQL output.
CAVEATS
- Dependencies
-
- Natural language description of the data requirement
- Database table structures and columns
- Specified database system
- Missing context
-
- Database system type (e.g., MySQL, PostgreSQL).
- Full input format specification beyond examples.
- Ambiguities
-
- "Specified database system" is referenced in constraints but not included in input example or variables.
QUALITY
- OVERALL
- 0.90
- CLARITY
- 0.95
- SPECIFICITY
- 0.90
- REUSABILITY
- 0.95
- COMPLETENESS
- 0.85
IMPROVEMENT SUGGESTIONS
- Add "database_system" field to variables and include it in the input example.
- Provide additional examples demonstrating JOIN, GROUP BY, ORDER BY, and WHERE clauses.
- Explicitly state that output must be solely the SQL query string with no additional text or explanations.
USAGE
Copy the prompt above and paste it into your AI of choice — Claude, ChatGPT, Gemini, or anywhere else you're working. Replace any placeholder sections with your own context, then ask for the output.
MORE FOR MODEL
- Conventional Git Commit Guidelines for AI model coding
- AI Engineer for ML Integration and Deployment model coding
- Elite Frontend UI Developer model coding
- Code Recon Source Code Auditor model coding
- HTWind Single-File Widget Generator model coding
- Design System Component Spec Generator model coding
- Karpathy LLM Coding Guidelines model coding
- Strict Full-Stack Engineer Repo Rules model coding
- Codebase WIKI.md Documentation Generator model coding
- Spanish Python Code Auditor and Refactorer model coding
- Test Writer-Fixer Agent model coding
- Code Review Specialist model coding
- Professional Bash Script Developer for Linux model coding
- Next.js POS App with FIFO Inventory and Reports model coding
- Code Review Specialist for Quality and Security model coding
- Antigravity Secure Coding Workflow Rules model coding
- Task-Oriented Code Review Expert model coding
- Senior Software Engineer Architect Rules model coding
- Ultrathinker Deep Reasoning Coding Workflow model coding
- Multi-Language Code Translator model coding
- Student GitHub SSH Setup Guide model coding
- Networking Engineer Portfolio Website Builder model coding
- Musician Portfolio Website with Booking and Animations model coding
- Python Code Interpreter Simulator model coding
- R Interpreter Terminal Simulator model coding