Generate SQL queries from schema only - AI-powered

Run this part only once This section: loads a list of all tables from the database hosted on [db4free](https://db4free.net/signup.php) extracts the database schema for each table and adds the table name converts the schema into a binary JSON format saves the schema ./chinookmysql.json file locally Now you can use chat to "talk" to your data! 🎉

Workflow Structure (20 nodes)
100%
Manual Trigger
When clicking "Test workflow"
My Sql
List all tables in a database
My Sql
Extract database schema
Set
Add table name to output
Convert To File
Convert data to binary
Read Write File
Save file locally
My Sql
Run SQL query
Set
Format query results
Langchain.chat Trigger
Chat Trigger
Read Write File
Load the schema from the local file
Extract From File
Extract data from file
Set
Combine schema data and chat input
Langchain.lm Chat Open Ai
OpenAI Chat Model
Langchain.agent
AI Agent
Langchain.memory Buffer Window
Window Buffer Memory
Set
Extract SQL query
If
Check if query exists
No Op
No Operation, do nothing
Merge
Combine query result and chat answer
Set
Prepare final output
Node Types:
default
action
transform
trigger
logic
Requires credentials

Prerequisites

Required Credentials (2)

My Sql

Used by: List all tables in a database, Extract database schema +1 more

Docs

OpenAI

Used by: OpenAI Chat Model

Docs

Complexity

Complex

Advanced features used. Requires n8n experience.

Setup time: ~35 min
Score: 60/100
Conditional Logic
6 Integrations

When to Use This Workflow

Real-time Response

React instantly when events happen - new orders, form submissions, or API calls.

Zero delay between trigger and action for time-sensitive workflows.

Time Savings

Replace repetitive manual tasks with reliable automation.

Reclaim hours every week for higher-value work.

Error Reduction

Eliminate human error from routine processes with consistent automation.

Improve accuracy and reliability across your workflows.

workflow.json
{
  "id": "P307QnrxpA1ddsM5",
  "meta": {
    "instanceId": "fb924c73af8f703905bc09c9ee8076f48c17b596ed05b18c0ff86915ef8a7c4a",
    "templateCredsSetupCompleted": true
  },
  "name": "Generate SQL queries from schema only - AI-powered",
  "tags": [],
  "nodes": [
    {
      "id": "b7c3ca47-11b3-4378-81fa-68b2f56b295e",
      "name": "OpenAI Chat Model",
      "type": "@n8n/n8n-nodes-langchain.lmChatOpenAi",
      "position": [
        1460,
        440
      ],
      "parameters": {
        "model": "gpt-4o",
        "options": {
...

Workflow Details

Nodes
29
Trigger
Event
Source
awesome
Added
Dec 4, 2025

Need Help?

Check out the official n8n documentation for detailed guides.

Related Workflows

SQL agent with memory

Run this part only once This section: downloads the example zip file from https://www.sqlitetutorial.net/sqlite-sample-...

Memorybufferwindow
Lmchatopenai
Http-request
Compression
13 nodesEvent
Curated

Chat with Postgresql Database

👨‍🎤 Setup 1. Add your postgresql and OpenAI credentials. 2. Click Chat button and start asking questions to your datab...

Chat
Agent
Lmchatopenai
Postgrestool
11 nodesEvent
Curated

MongoDB Agent

AI Agent powered by OpenAI and MongoDB This flow is designed to work as an AI autonomous agent that can get chat message...

Lmchatopenai
Mongodbtool
Memorybufferwindow
Chat
8 nodesEvent
Curated

🔥📈🤖 AI Agent for n8n Creators Leaderboard - Find Popular Workflows

AI Agent for n8n Creator Leaderboard Stats https://github.com/teds-tech-talks/n8n-community-leaderboard

Http-request
Lmchatopenai
Executeworkflow
Chat
43 nodesEvent
Curated

Chat with GitHub OpenAPI Specification using RAG (Pinecone and OpenAI)

Indexing content in the vector database This part of the workflow is responsible for extracting content, generating embe...

Http-request
Vectorstorepinecone
Documentdefaultdataloader
Textsplitterrecursivecharactertextsplitter
17 nodesEvent
Curated

Build a Tax Code Assistant with Qdrant, Mistral.ai and OpenAI

Step 1. Download the Tax Code PDF [Read more about handling Zip Files](https://docs.n8n.io/integrations/builtin/core-nod...

Embeddingsmistralcloud
Documentdefaultdataloader
Textsplitterrecursivecharactertextsplitter
Http-request
38 nodesEvent
Curated