This project is a web application built with Streamlit that generates SQL queries based on user input and the columns of an uploaded CSV file. It uses Google's Generative AI (Gemini) to create the SQL queries.
- Upload a CSV file to the application.
- Enter a text query to describe the desired SQL operation.
- The application generates a SQL query based on the input and the structure of the uploaded CSV file.
- Easy CSV file upload.
- Instant SQL query generation using Google's Generative AI.
- Clean and user-friendly interface built with Streamlit.
- Python 3.7+
- Streamlit
- Pandas
- Google Generative AI SDK
- SQLite3 (optional, used for data storage and querying)
-
Clone the repository:
git clone <repository_url> cd <repository_name>
-
Install the required packages:
pip install streamlit pandas google-generative-ai sqlite3
-
Configure your Google Gemini API key:
- Open the
sql_query_generator.py
file. - Replace
"ADD YOUR GEMINI API KEY"
with your actual Gemini API key:GOOGLE_API_KEY = "your_actual_gemini_api_key_here"
- Open the
-
Run the Streamlit application:
streamlit run sql_query_generator.py
-
Open your web browser and navigate to
http://localhost:8501
. -
Upload your CSV file and enter your query in the text input box.
-
Click the "GENERATE SQL Query" button to generate the SQL query based on your input.
-
Upload CSV File:
- Upload a file named
data.csv
with columnsname
,age
,city
.
- Upload a file named
-
Enter Query:
- Example query: "Select all columns where age is greater than 25."
-
Generated SQL Query:
SELECT * FROM data WHERE age > 25;
This project is licensed under the MIT License. See the LICENSE file for details.