Generate SQL queries from schema only - AI-powered
n8n template #2508Summary
Use templateThis workflow is a modification of the previous template on how to create an SQL agent with LangChain and SQLite. The key difference – the agent has access only to the database schema, not to the actual data. To achieve this, SQL queries are made outside the AI Agent node, and the results are never passed back to the agent. This approach allows the agent to generate SQL queries based on the structure of tables and their relationships, without having to access the actual data. This makes the process more secure and efficient, especially in cases where data confidentiality is crucial. 🚀 Setup To get started with this workflow, you’ll need to set up a free MySQL server and import your database
How to set it up
- Open template #2508 on n8n.io and click Use for free, or copy the template JSON and paste it onto an empty canvas in n8n.
- Create 2 credentials under Credentials → Add credential: MySQL, OpenAI Chat Model. Then open each of those nodes and pick the credential.
- Check the model in the AI Agent node. The template may point at a model your account can't use; swap it for one you have access to.
- Click Execute workflow and step through each node's output to confirm the data looks right.
- Toggle the workflow to Active so its trigger runs on its own.
Hand off to your agent
Prompt
Help me set up the n8n workflow "Generate SQL queries from schema only - AI-powered" (https://n8n.io/workflows/2508). It uses: MySQL, AI Agent, OpenAI Chat Model, Simple Memory. Import the template JSON into my n8n instance, list every credential I need to create, and walk me through testing it.
Paste into Claude Code and it will do the rest.
Apps and nodes
Questions
Yes. Yulia published it free on n8n.io as a verified creator, and it has 38K views. It runs on n8n Cloud or a self-hosted n8n instance.
MySQL, OpenAI Chat Model. The other 2 nodes are built into n8n.
Similar workflows
NameViews
- AI agent chat780K
- Building Your First WhatsApp Chatbot332K
- Angie, personal AI assistant with Telegram voice and text326K
- Build Your First AI Data Analyst Chatbot134K
- Create a Branded AI-Powered Website Chatbot88K
- Conversational Telegram Bot with GPT-5/GPT-4o for Text and Voice Messages82K
- Chat with Postgresql Database74K
- AI chatbot that can search the web72K