A Streamlit application that uses Google's Gemini AI to convert natural language questions into SQL queries, executes them on a local SQLite database, and displays the result.
- Python 3.10+
- Streamlit (Frontend)
- Google GenAI SDK (
google-genai) - SQLite (Database)
-
Google Gemini API Key:
- Get your free key here: Google AI Studio
-
Python Installed: Make sure Python is installed on your system.
-
Clone the repository:
git clone https://github.com/yash-cs-ai/Text-to-Sql-using-gemini.git cd your-repo-name -
Create a virtual environment (Optional but Recommended):
python -m venv venv # Windows venv\Scripts\activate # Mac/Linux source venv/bin/activate
-
Install dependencies:
pip install streamlit google-genai python-dotenv pandas
-
Set up Environment Variables:
Create a file named
.envin the root folder and add your API key:GEMINI_API_KEY="your_google_api_key_here"
Before running the app, you need to create the dummy database.
-
Create a file named
sql.py(if not already present) with the database creation logic. -
Run the script to generate
student.db:python sql.py
This will create the
student.dbfile with sample data (Name, Class, Section).
Run the Streamlit app:
streamlit run app.p