+ GenAI & RAG

Text-to-SQL Chatbot

Ask questions in plain English and get SQL results: connects to MySQL dynamically, generates SELECT-only queries with LLMs and streams answers.

Source code is private

Database connection form interface for entering MySQL connection string and database name

Overview

A FastAPI + React chatbot that converts natural language into SQL. It connects to any MySQL database at runtime, extracts and caches the schema, classifies each request (schema question, SQL generation or refused write operation) and executes SELECT-only queries safely. Answers stream to the UI over Server-Sent Events, and conversations are logged in SQLite.

Highlights

  • Natural language to SQL with Gemini 2.0 Flash / GPT-4o-mini
  • Read-only safety: SELECT-only execution, write operations refused
  • Dynamic MySQL connection with cached schema extraction
  • Streaming answers over Server-Sent Events
  • Conversation history and sessions stored in SQLite

Tech stack

  • Python
  • FastAPI
  • React
  • LangChain
  • Gemini
  • OpenAI
  • SQLAlchemy
  • MySQL
  • SQLite