An AI-powered app that converts plain English questions into SQL queries and executes them against a SQLite database.
- Natural language to SQL using Groq (Llama 3.1)
- Auto-executes queries against SQLite
- Results shown as sortable table with CSV download
- Plain English explanation of results
- 10 example questions to try instantly
- Query history panel
- LLM: Llama 3.1 8B via Groq API (free)
- Database: SQLite with SQLAlchemy
- Backend: LangChain + Python
- Frontend: Streamlit
git clone https://github.com/YOUR_USERNAME/text-to-sql.git
cd text-to-sqlpip install -r requirements.txt- Go to console.groq.com
- Sign up with Google
- Create an API key
GROQ_API_KEY=gsk_xxxxxxxxxxxxxxxxxxxxxxxxpython sample_db.pypython -m streamlit run app.pyOpen http://localhost:8501
- "Show me the top 5 most expensive products"
- "Which customer has spent the most money?"
- "What is the total revenue per product category?"
- "Show me all orders placed in March 2024"
text-to-sql/
├── app.py # Streamlit frontend
├── sql_pipeline.py # SQL generation + execution pipeline
├── sample_db.py # Creates demo SQLite database
├── requirements.txt # Dependencies
├── .env # API keys (not committed)
└── README.md # This file