AutomationMart
Home/Browse/Generate SQL queries from schema only - AI-powered
n8n

Generate SQL queries from schema only - AI-powered

n8nn8n20 modulesv1.0
UNSUPPORTED_SLUG_FORMAT

This 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 proc

At a glance

Generate SQL queries from schema only - AI-powered is a ready-made n8n workflow you import as a workflow JSON file — no build required. It connects UNSUPPORTED_SLUG_FORMAT. It's free to download. Follow the 5-step import below to go live in minutes.

Platform
n8n
Connects
UNSUPPORTED_SLUG_FORMAT
Modules
20
Price
Free
Version
v1.0
Generate SQL queries from schema only - AI-powered workflow diagram

About this workflow

This 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 (check Step 1 and 2 in this tutorial). Of course, you can switch MySQL to another SQL database such as PostgreSQL, the principle remains the same. The key is to download the schema once and save it locally to avoid repeated remote connections. Run the top part of the workflow once to download and store the MySQL chinook database schema file on the server. With this approach, we avoid the need to repeatedly connect to a remote db4free database and fetch the schema every time. As a result, we reach greater processing speed and efficiency. 🗣️ Chat with your data 1. Start a chat: send a message in the chat window. 2. The workflow loads the locally saved MySQL database schema, without having the ability to touch the actual data. The file contains the full structure of your MySQL database for analysis. 3. The Langchain AI Agent receives the schema, your input and begins to work. 4. The AI Agent generates SQL queries and brief comments based solely on the schema and the user’s message. 5. An IF node checks whether the AI Agent has generated a query. When: - Yes: the AI Agent passes the SQL query to the next MySQL node for execution. - No: You get a direct answer from the Agent without further action. 6. The workflow formats the results of the SQL query, ensuring they are convenient to read and easy to understand. 7. Once formatted, you get both the Agent answer and the query result in the chat window. 🌟 Example queries Try these sample queries to see the schema-driven AI Agent in action: 1. Would you please list me all customers from Germany? 2. What are the music genres in the database? 3. What tables are available in the database? 4. Please describe the relationships between tables. - In this example, the AI Agent does not need to create the SQL query. And if you prefer to keep the data private, you can manually execute the generated SQL query in your own environment using any database client or tool you trust 🗄️ 💭 The AI Agent memory node does not store the actual data as we run SQL-queries outside the agent. It contains the database schema, user questions and the initial Agent reply. Actual SQL query results are passed to the chat window, but the values are not stored in the Agent memory.

n8n

How to import this n8n workflow

  1. 1

    Download the workflow JSON file after purchase.

  2. 2

    Open n8n → click the menu → Import from File.

  3. 3

    Select the downloaded JSON and import.

  4. 4

    Set up credentials for each node that requires them.

  5. 5

    Click Execute Workflow to test, then activate.

Setup guide

Setup guide included

Purchase to unlock the full step-by-step guide

Related N8n workflows

Build your own PostgreSQL MCP server

This n8n demonstrates how to build a simple PostgreSQL MCP server to manage your PostgreSQL database such as HR, Payroll, Sale, Inventory and More! This MCP example is based off an official MCP reference implementation which can be found here - How it works A MCP server trigger is used and connected to 5 tools: 2 postgreSQL and 3 custom workflow. The 2 postgreSQL tools are simple read-only queries and as such, the postgreSQL tool can be simply used. The 3 custom workflow tools are used for se

Free

Convert HTML & PDF files to PNG images with CustomJS PDF Toolkit

This n8n workflow shows how to convert PDF files into PNG format with the PDF Toolkit from www.customjs.space. @custom-js/n8n-nodes-pdf-toolkit Notice Community nodes can only be installed on self-hosted instances of n8n. What this workflow does - Generate PDF file from the requested HTML. - Convert the PDF to PNG images. - Use a Code node to handle URLs that point to PDF files. - Convert the PDF to PNG format. Requirements - Self-hosted n8n instance. - CustomJS API key for converting PDF to PNG

Free

Automated error handling with email alerts & smart workflow deactivation

How it works This workflow automatically handles errors in your n8n workflows by: 1. Detecting when an error occurs and capturing the error details 2. Sending an email notification with the error message and affected node 3. Allowing you to deactivate the workflow or ignore the error via email response 4. Optionally rerouting the error notification to another user for approval The workflow includes two templates: a basic version with simple deactivate/ignore options, and an advanced version that

Free

Run scenarios with custom inputs and respond via webhook in Make

Trigger custom scenarios with specific inputs via a webhook in Make, then respond instantly using Custom WebHook, Make: Run a Scenario With Inputs, and Webhook Response.

Free

Identify Segment users from Autopilot events

Every time a new contact is created in Autopilot, Make will automatically identify a user in Segment.

Free

🎓 Learn API Fundamentals with an Interactive Hands-On Tutorial Workflow

How it works This template is an interactive, hands-on tutorial designed to demystify what an API is and how it works, right inside your n8n canvas. It uses a simple restaurant analogy to explain the core concepts: You are the "Client" (an HTTP Request node). The Kitchen is the "Server" (a Webhook node). The API is the Menu and the Waiter—the set of rules for how you can ask for things and get a response. The workflow is a series of self-contained lesso

Free

Create a RAG system with Paul Essays, Milvus, and OpenAI for cited answers

Create a RAG System with Paul Essays, Milvus, and OpenAI for Cited Answers This workflow automates the process of creating a document-based AI retrieval system using Milvus, an open-source vector database. It consists of two main steps: 1. Data collection/processing 2. Retrieval/response generation The system scrapes Paul Graham essays, processes them, and loads them into a Milvus vector store. When users ask questions, it retrieves relevant information and generates responses with citations. St

Free

Telegram AI bot assistant: ready-made template for voice & text messages

Free template for voice & text messages with short-term memory This n8n workflow template is a blueprint for an AI Telegram bot that processes both voice and text messages. Ready to use with minimal setup. The bot remembers the last several messages (10 by default), understands commands and provides responses in HTML. You can easily swap GPT-4 and Whisper for other language and speech-to-text models to suit your needs. Core Features - Text: send or forward messages - Voice: transcr

Free

Reviews

No reviews yet

Be the first to buy and share your experience.

Leave a review

Sign in to share your experience with this workflow.

Log in to review
Free
No ratings yet

Create a free account to purchase workflows.

  • JSON blueprint — instant download
  • Setup guide PDF included
  • 5 downloads · valid 30 days
  • Works with n8n

Need help setting this up?

Book a 3-hour live setup session with an Agility consultant.

₹2,499/ session
3 hrs · video call
  • Configure live on Google Meet / Zoom
  • Free follow-up if workflow has defects
  • Platform expert assigned to you
Book installation session
Free