|
| 1 | + |
| 2 | +# SQL Query Generator with Google Gemini |
| 3 | + |
| 4 | +This project is a Streamlit application that converts English questions into SQL queries using Google Gemini's generative AI capabilities. It allows users to retrieve data from an SQLite database named **STUDENT**, which contains information about students, their classes, sections, and marks. |
| 5 | + |
| 6 | +## Table of Contents |
| 7 | + |
| 8 | +- [Features](#features) |
| 9 | +- [Technologies Used](#technologies-used) |
| 10 | +- [Installation](#installation) |
| 11 | +- [Usage](#usage) |
| 12 | +- [Example Queries](#example-queries) |
| 13 | +- [Database Schema](#database-schema) |
| 14 | +- [Contributing](#contributing) |
| 15 | +- [License](#license) |
| 16 | + |
| 17 | +## Features |
| 18 | + |
| 19 | +- Convert natural language questions into SQL queries. |
| 20 | +- Execute generated SQL queries against an SQLite database. |
| 21 | +- User-friendly interface built with Streamlit. |
| 22 | + |
| 23 | +## Technologies Used |
| 24 | + |
| 25 | +- [Streamlit](https://streamlit.io/) - For building the web application. |
| 26 | +- [SQLite](https://www.sqlite.org/index.html) - Lightweight database to store student records. |
| 27 | +- [Google Generative AI](https://developers.google.com/generative-ai) - To generate SQL queries from text input. |
| 28 | +- [Python](https://www.python.org/) - Programming language used to build the application. |
| 29 | + |
| 30 | +## Installation |
| 31 | + |
| 32 | +To get started, clone the repository and install the required dependencies. |
| 33 | + |
| 34 | +### Prerequisites |
| 35 | + |
| 36 | +- Python 3.7 or higher |
| 37 | +- pip (Python package installer) |
| 38 | + |
| 39 | +### Steps to Install |
| 40 | + |
| 41 | +1. **Clone the repository:** |
| 42 | + ```bash |
| 43 | + git clone https://github.com/yourusername/sql-query-generator.git |
| 44 | + cd sql-query-generator |
| 45 | + ``` |
| 46 | + |
| 47 | +2. **Create a virtual environment (optional but recommended):** |
| 48 | + ```bash |
| 49 | + python -m venv venv |
| 50 | + source venv/bin/activate # On Windows use `venv\Scripts\activate` |
| 51 | + ``` |
| 52 | + |
| 53 | +3. **Install required packages:** |
| 54 | + ```bash |
| 55 | + pip install -r requirements.txt |
| 56 | + ``` |
| 57 | + |
| 58 | +4. **Set up your environment variables:** |
| 59 | + - Create a `.env` file in the project root and add your Google API key: |
| 60 | + ``` |
| 61 | + GOOGLE_API_KEY=your_api_key_here |
| 62 | + ``` |
| 63 | +
|
| 64 | +## Usage |
| 65 | +
|
| 66 | +1. Run the Streamlit application: |
| 67 | + ```bash |
| 68 | + streamlit run app.py |
| 69 | + ``` |
| 70 | + |
| 71 | +2. Open your browser and go to `http://localhost:8501`. |
| 72 | + |
| 73 | +3. Input your question in the text box and click the "Ask the question" button. The app will generate an SQL query based on your input and execute it against the database, displaying the results. |
| 74 | + |
| 75 | +## Example Queries |
| 76 | + |
| 77 | +Here are some example questions you can ask: |
| 78 | + |
| 79 | +- "How many entries of records are present?" |
| 80 | +- "Tell me all the students studying in Data Science class?" |
| 81 | +- "What is the average marks of students?" |
| 82 | + |
| 83 | +## Database Schema |
| 84 | + |
| 85 | +The database **STUDENT** has the following schema: |
| 86 | + |
| 87 | +| Column | Type | Description | |
| 88 | +|---------|---------|--------------------------------------| |
| 89 | +| NAME | TEXT | Name of the student | |
| 90 | +| CLASS | TEXT | Class of the student | |
| 91 | +| SECTION | TEXT | Section of the student | |
| 92 | +| MARKS | INTEGER | Marks obtained by the student | |
| 93 | + |
| 94 | +## Contributing |
| 95 | + |
| 96 | +Contributions are welcome! Please open an issue or submit a pull request if you'd like to contribute. |
| 97 | + |
| 98 | +1. Fork the repository. |
| 99 | +2. Create your feature branch (`git checkout -b feature/AmazingFeature`). |
| 100 | +3. Commit your changes (`git commit -m 'Add some AmazingFeature'`). |
| 101 | +4. Push to the branch (`git push origin feature/AmazingFeature`). |
| 102 | +5. Open a pull request. |
| 103 | + |
| 104 | +## License |
| 105 | + |
| 106 | +This project is licensed under the MIT License. See the [LICENSE](LICENSE) file for details. |
| 107 | + |
| 108 | +``` |
| 109 | +
|
| 110 | +### Explanation of Sections |
| 111 | +
|
| 112 | +1. **Title & Introduction:** Gives an overview of what the project is about. |
| 113 | +2. **Table of Contents:** Helps users navigate the document quickly. |
| 114 | +3. **Features:** Highlights the main features of the app. |
| 115 | +4. **Technologies Used:** Lists the technologies and frameworks involved in the project. |
| 116 | +5. **Installation:** Step-by-step guide on how to install and set up the project. |
| 117 | +6. **Usage:** Instructions on how to run the app and interact with it. |
| 118 | +7. **Example Queries:** Provides sample questions users can input to test the functionality. |
| 119 | +8. **Database Schema:** Describes the structure of the SQLite database. |
| 120 | +9. **Contributing:** Encourages collaboration and outlines how others can contribute to the project. |
| 121 | +10. **License:** States the licensing information for the project. |
| 122 | +
|
| 123 | +### Tips for Customization |
| 124 | +
|
| 125 | +- Replace placeholders like `yourusername` and `your_api_key_here` with actual values relevant to your project. |
| 126 | +- Adjust the content based on any additional features or changes you have made. |
| 127 | +- Make sure to include any additional documentation or instructions relevant to your specific project needs. |
0 commit comments