Workflows

Generate SQL queries from schema

Explore this Workflow. Built for next generation AI app & agent building.

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 only has access to the database schema, not the actual data. 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

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.  
  3. 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.
  4.  
  5. The Langchain AI Agent receives the schema, your input and begins to work.
  6.  
  7. The AI Agent generates SQL queries and brief comments based solely on the schema and the user’s message.
  8.  
  9. 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.
     
  1. The workflow formats the results of the SQL query, ensuring they are convenient to read and easy to understand.
  2.  
  3. 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.  
  3. What are the music genres in the database?
  4.  
  5. What tables are available in the database?
  6.  
  7. 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.

Workflow Elements
MySQL
AI Agent
OpenAI Chat Model
Window Buffer Memory (easiest)
Edit Fields (Set)
No Operation, do nothing
If
Merge
Sticky Note
Manual Trigger
Read/Write Files from Disk
Convert to File
Extract from File
Chat Trigger

Other workflows like this one

Your connected stack awaits to automate AI workflows with 24-7 uptime performance and engagement

Actioning Your Meeting Next Steps using Transcripts and AI

HTTP Request
Edit Fields (Set)
Google Drive
Switch
Google Calendar

Breakdown Documents into Study Notes using Templating MistralAI and Qdrant

Merge
Edit Fields (Set)
Loop Over Items (Split in Batches)
Switch
Wait

Build a Tax and Financial Assistant with AI

HTTP Request
Edit Fields (Set)
Loop Over Items (Split in Batches)
Switch
Compression

Building Chatbot for Movie Recommendations

GitHub
HTTP Request
Merge
Edit Fields (Set)
Sticky Note

WordPress or Webflow AI Chatbot with Rantir and OpenAI

HTTP Request
Merge
Postgres
Edit Fields (Set)
Loop Over Items (Split in Batches)

AI-powered WooCommerce Support-Agent

HTTP Request
If
Merge
Edit Fields (Set)
Webhook
Average ROI

401%

In ROI when switching to Rantir for automating their website, operations & integrations with AI.
average cost savings

+$128K

In Average savings from SaaS subscriptions, annually, and 2 optimized employee positions
startups Funding

$2.3B

Over $2 Billion dollars have been raised by our startup clients using Rantir for Services & Software.

They love working with Rantir

12x Signups for
Virtual Events

"I highly recommend Rantir, they are a great dev team with quick turn around on all projects and requests. We recently worked with them on updating our website and any changes, updates or modifications I needed were always taken care of quickly!"

Paige J.
Design Exp. Director

4X in Traffic

"The team at Rantir has lived up to every definition of the word "partner". They're adaptive, fast, and flexible (all the things you'd hope for). We're so thrilled with what we've accomplished so far and look forward to working alongside them in the future."

Kate W.
Marketing Director, Scoop

188% More Signups

"Working with the Rantir team was a pleasure. They guided us through the whole process from design to implementation, creating a great site on a tight deadline. They were responsive and adaptable throughout, and we'd be happy to work with them again in the future."

Garath W.
Growth Manager

Acquisition & Merger

"Working with the Rantir team early on made combined design and development with early conversations to implement AI within Onder. We were happy to work together to help bring no-code, with code and AI."

David K.
Head of Product

Over 700+ Talent and Rantir Partners to help you get started. Including Us.

Hire us for customization & AI development.  

Graphic.
AI No-Coder
Tayler F.
I generate beautiful, connected, landers with AI No Code software
Generative AI Art & Video
Avatar Placeholder
Malika V.
I onboard you to Flux, Midjourney & Synthesia or HeyGen
AI Marketing Flows
Avatar Placeholder
Bruno F.
I teach AI Marking & automated outreach
Generative software engineer
Avatar Placeholder
Christian B.
I help you onboard Cursor or Rantir with generating code

Join the Rantir Community around the world

Map.

AI Agents are the new Apps. Websites are the new Software.

Rantir University for learning how to build powerful AI Agents & Software you own.

Graphic.