Convert natural language questions to SQL queries using Google's Generative AI! π€

Text-2-SQL-v3/
βββ app.py # Main Flask application
βββ requirements.txt # Python dependencies
βββ static/
β βββ css/ # Stylesheets
β βββ js/ # JavaScript files
βββ templates/
β βββ base.html # Base template
β βββ index.html # Main application page
βββ uploads/ # Temporary CSV storage
βββ model_cache/ # Cached model files
- π Upload and analyze CSV files
- π¬ Natural language to SQL conversion using Google's Generative AI
- π Automatic data visualization
- π Statistical summaries
- π― Interactive query examples
- π± Responsive design
- Python 3.8 or higher
- pip (Python package manager)
- Git
- Google API key for Generative AI
- Go to the Google Cloud Console
- Create a new project or select an existing one
- Enable the Generative Language API
- Create credentials (API key) for the Generative Language API
- Copy your API key
- Add it to the
.envfile:GOOGLE_API_KEY=your_google_api_key_here
git clone https://github.com/yourusername/Text-2-SQL-v3.git
cd Text-2-SQL-v3# Create virtual environment
python -m venv venv
# Activate virtual environment
# For Windows
venv\Scripts\activate
# For Unix or MacOS
source venv/bin/activate
# Install dependencies
pip install -r requirements.txtpython app.pyVisit http://localhost:5000 in your web browser π
- Upload your CSV file using the upload button or drag-and-drop
- Wait for the data preview to load
- Type your question in natural language or use example queries
- Click "Generate Insights" to get SQL and results
- Explore visualizations and statistics in the results section
- Backend: Flask (Python)
- AI Model: Google Generative AI (Gemini) for text-to-SQL conversion
- Frontend: HTML5, CSS3, JavaScript
- Data Processing: Pandas, NumPy
- Visualization: Matplotlib, Seaborn
- "Show all rows from the table"
- "What is the average [column]?"
- "Find records where [column] > [value]"
- "Show the top 5 rows"
- Maximum file size: 10MB
- Supported format: CSV
- Model files are cached locally after first run
- Requires active internet connection for first-time model download
Feel free to:
- π Report bugs
- π‘ Suggest enhancements
- π Submit pull requests
This project is licensed under the MIT License - see the LICENSE file for details.
- Google for the Generative AI API
- Flask team for the web framework
- Open source community for various libraries