Spaces:
Build error
Build error
Update README.md
Browse files
README.md
CHANGED
|
@@ -10,4 +10,125 @@ pinned: false
|
|
| 10 |
license: mit
|
| 11 |
---
|
| 12 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 13 |
Check out the configuration reference at https://huggingface.co/docs/hub/spaces-config-reference
|
|
|
|
| 10 |
license: mit
|
| 11 |
---
|
| 12 |
|
| 13 |
+
# SQL Query Generator
|
| 14 |
+
|
| 15 |
+
Effortlessly transform your natural language inputs into SQL queries using this Streamlit application powered by Google Generative AI.
|
| 16 |
+
|
| 17 |
+
## Features
|
| 18 |
+
- Generate SQL queries from natural language input.
|
| 19 |
+
- Optionally specify schema and table names for precise query generation.
|
| 20 |
+
- Get sample expected responses for the generated SQL query.
|
| 21 |
+
- Receive a simple explanation of the SQL query.
|
| 22 |
+
|
| 23 |
+
---
|
| 24 |
+
|
| 25 |
+
## Prerequisites
|
| 26 |
+
### 1. Install Required Tools
|
| 27 |
+
Ensure the following tools are installed:
|
| 28 |
+
- Python 3.8+
|
| 29 |
+
|
| 30 |
+
### 2. Obtain API Key
|
| 31 |
+
1. Get an API key for Google Generative AI from [Google Cloud Console](https://console.cloud.google.com/).
|
| 32 |
+
2. Save the API key for later configuration.
|
| 33 |
+
|
| 34 |
+
---
|
| 35 |
+
|
| 36 |
+
## Installation
|
| 37 |
+
|
| 38 |
+
### Clone the Repository
|
| 39 |
+
```bash
|
| 40 |
+
# Clone this repository
|
| 41 |
+
git clone <repository_url>
|
| 42 |
+
cd <repository_folder>
|
| 43 |
+
```
|
| 44 |
+
|
| 45 |
+
### Create and Activate a Virtual Environment
|
| 46 |
+
```bash
|
| 47 |
+
# Create a virtual environment
|
| 48 |
+
python -m venv venv
|
| 49 |
+
|
| 50 |
+
# Activate the virtual environment
|
| 51 |
+
# For Windows:
|
| 52 |
+
venv\Scripts\activate
|
| 53 |
+
# For MacOS/Linux:
|
| 54 |
+
source venv/bin/activate
|
| 55 |
+
```
|
| 56 |
+
|
| 57 |
+
### Install Dependencies
|
| 58 |
+
```bash
|
| 59 |
+
# Install required Python libraries
|
| 60 |
+
pip install -r requirements.txt
|
| 61 |
+
```
|
| 62 |
+
|
| 63 |
+
---
|
| 64 |
+
|
| 65 |
+
## Configuration
|
| 66 |
+
1. Create a `.env` file in the root of your project directory.
|
| 67 |
+
2. Add your Google API key to the `.env` file as follows:
|
| 68 |
+
```env
|
| 69 |
+
GOOGLE_API_KEY="<your_google_api_key>"
|
| 70 |
+
```
|
| 71 |
+
|
| 72 |
+
---
|
| 73 |
+
|
| 74 |
+
## Usage
|
| 75 |
+
|
| 76 |
+
### Run the Application
|
| 77 |
+
```bash
|
| 78 |
+
streamlit run app.py
|
| 79 |
+
```
|
| 80 |
+
|
| 81 |
+
### Input Details
|
| 82 |
+
1. Enter your natural language query in the text box.
|
| 83 |
+
2. Optionally, specify a schema name.
|
| 84 |
+
3. Enter a table name (this is mandatory).
|
| 85 |
+
4. Click on **Generate SQL Query**.
|
| 86 |
+
|
| 87 |
+
### Outputs
|
| 88 |
+
The application will provide:
|
| 89 |
+
1. The generated SQL query.
|
| 90 |
+
2. A sample tabular response for the query.
|
| 91 |
+
3. A simple explanation of the SQL query.
|
| 92 |
+
|
| 93 |
+
---
|
| 94 |
+
|
| 95 |
+
## Project Structure
|
| 96 |
+
```
|
| 97 |
+
.
|
| 98 |
+
βββ app.py # Main Streamlit app
|
| 99 |
+
βββ .env # Environment file for API key
|
| 100 |
+
βββ requirements.txt # Python dependencies
|
| 101 |
+
βββ README.md # This file
|
| 102 |
+
```
|
| 103 |
+
|
| 104 |
+
---
|
| 105 |
+
|
| 106 |
+
## Troubleshooting
|
| 107 |
+
### 1. Error: `Please enter the table name!`
|
| 108 |
+
- Ensure the **Table Name** field is not empty.
|
| 109 |
+
|
| 110 |
+
### 2. API Key Issues
|
| 111 |
+
- Verify the API key in your `.env` file is correct and has sufficient permissions.
|
| 112 |
+
|
| 113 |
+
### 3. Missing Dependencies
|
| 114 |
+
- Ensure all dependencies are installed via `pip install -r requirements.txt`.
|
| 115 |
+
|
| 116 |
+
---
|
| 117 |
+
|
| 118 |
+
## Contributing
|
| 119 |
+
Feel free to fork this repository, raise issues, or submit pull requests. Contributions are always welcome!
|
| 120 |
+
|
| 121 |
+
---
|
| 122 |
+
|
| 123 |
+
## License
|
| 124 |
+
This project is licensed under the MIT License.
|
| 125 |
+
|
| 126 |
+
---
|
| 127 |
+
|
| 128 |
+
## Acknowledgments
|
| 129 |
+
- [Streamlit](https://streamlit.io/)
|
| 130 |
+
- [Google Generative AI](https://cloud.google.com/genai)
|
| 131 |
+
- [dotenv](https://pypi.org/project/python-dotenv/)
|
| 132 |
+
|
| 133 |
+
|
| 134 |
Check out the configuration reference at https://huggingface.co/docs/hub/spaces-config-reference
|