By the end of this video, you will have a Python bot that takes a plain-English question, writes the SQL automatically, runs it against your database, and returns a clean result table. No SQL knowledge needed to use it.
In this project you will build a complete schema-aware Text-to-SQL pipeline from scratch:
→ Create a realistic SQLite database with 3 tables and 120 rows
→ Extract the live schema automatically using PRAGMA commands
→ Build a schema-grounded prompt — no hallucinated column names
→ Generate SQL using LangChain LCEL + Groq (free) / Claude / OpenAI
→ Execute queries safely — SELECT only, errors as data not exceptions
→ Handle out-of-scope questions with an honest NOT_SQL refusal
→ Wrap everything into a production TextToSQL class
Works with Groq (free), Claude (Anthropic), and OpenAI. One flag switches between them.
📓 FREE NOTEBOOK — link below
⭐ Star it on GitHub if it saves you time
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
🔗 LINKS
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
📁 GitHub Notebook → https://github.com/notebooklearnings/...
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
🛠️ STACK
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
• LangChain + LCEL
• SQLite (built into Python — no install)
• Groq llama-3.3-70b-versatile (free tier)
• Anthropic Claude / OpenAI (optional)
• pandas + tabulate (result display)
• Python 3.10+
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
⏱️ TIMESTAMPS
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
00:00 ## Text-to-SQL Bot — Ask Your Database Questions in Plain English
00:35 # Text-to-SQL Bot — Ask Your Database Questions in Plain English | Free Notebook
02:01 ## How Text-to-SQL Works — The Mental Model
03:10 ## Setup — Install and Configure
06:13 ## Step 1 — Build a Realistic Sample Database
08:23 ## Step 2 — Extract the Schema Automatically
09:48 ## Step 3 — Build the Schema-Aware SQL Prompt
11:41 ## Step 4 — Execute the SQL and Return Results
13:30 ## Step 5 — Wire It Together With an ask() Function
15:39 ## Production Pattern — TextToSQL Class
18:45 ## What You Built Today
19:46 ## Get the Free Notebook
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
📌 ABOUT THIS CHANNEL
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
Notebook Learnings — one complete AI/ML project per video.
Deep explanations, real code, and a free runnable notebook every time.
Subscribe for weekly Python + AI projects → @NoteBookLearnings
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
#Python #LangChain #TextToSQL #SQL #NaturalLanguageSQL #GenerativeAI #LLM #Groq #SQLite #OpenAI #Anthropic #MachineLearning #AIPython #DataScience #LangChainTutorial #PythonProject #AIProject #NotebookLearnings #SQLBot #NLP
```
---