A state-of-the-art Natural Language to SQL conversion engine and interactive query workbench. Translates complex plain-English questions into optimized, syntactically flawless SQL queries with schema awareness, automatic relational JOIN detection, self-correction, and multi-dialect translation.
- Neural AI Engine (Default): Powered by Google Gemini 2.5 Flash and Groq LLaMA 3.3 / Qwen for 100% human-level accuracy on complex multi-table joins, subqueries, CTEs, window functions, and nested aggregations.
- Smart Local Rule Engine (Offline Fallback): Automatically activates when offline or running with zero API keys.
- Sample Databases: Connect to built-in SQLite databases (E-Commerce, Company HR, University).
- Custom Database Upload: Upload any
.dbor.sqlitefile for instant schema mapping and live query testing. - Foreign Key Awareness: Automatically detects foreign keys and creates accurate
JOINconditions with table alias qualification (p.price,c.name,o.total_amount).
Instantly generates syntax for:
- SQLite (Standard SQL)
- MySQL
- PostgreSQL
- Microsoft SQL Server (T-SQL)
- Oracle SQL
- Live execution on connected databases or in-memory preview.
- Detailed SQL clause breakdown (
SELECT,FROM,WHERE,GROUP BY,ORDER BY,LIMIT). - Natural language explanation of generated queries.
- One-click copy and CSV Export.
git clone https://github.com/harshrameshnerkar/Text-to-SQL.git
cd Text-to-SQL
pip install -r requirements.txtCopy the example environment template:
cp .env.example .envAdd your free Google Gemini or Groq API key in .env:
GEMINI_API_KEY=your_gemini_api_key_here
GROQ_API_KEY=your_groq_api_key_here(Get a free key from Google AI Studio or Groq Console - no credit card required).
python app.pyOpen http://localhost:5000 in your browser.
Text-to-SQL/
├── app.py # Flask web application server & REST APIs
├── sql_engine.py # Hybrid Neural AI & Schema-Aware SQL Engine
├── init_db.py # Sample database generator
├── requirements.txt # Python dependencies
├── .env.example # Environment variables template
├── .gitignore # Git ignore rules (protects .env)
├── README.md # Documentation
│
├── databases/ # SQLite sample databases
│ ├── ecommerce.db
│ ├── company.db
│ └── university.db
│
├── templates/
│ └── index.html # Glassmorphic Dark-Mode UI
│
└── static/
├── style.css # Design system & responsive styles
└── main.js # Frontend state, schema explorer & API connector
Harsh Nerkar
- GitHub: @harshrameshnerkar
- Email: harshrameshnerkar@gmail.com
This project is licensed under the MIT License.