A simple web app that uses OpenAI's GPT model to translate natural language (English) queries into SQL queries.
- Translate plain English into valid SQL statements
- Built using Flask and OpenAI's API
- Easy-to-use web interface
Eng_to_SQL_translator/ │ ├── app.py # Main Flask backend ├── templates/ │ └── index.html # Frontend HTML (with embedded JS) └── README.md # This file
- Python 3.7+
- Flask
- OpenAI Python SDK
Install them using:
pip install flask openai
Get your API key from https://platform.openai.com/account/api-keys
Update app.py with your key:
client = OpenAI( api_key="your-api-key-here" )
-
Clone the repo:
git clone https://github.com/your-username/Eng_to_SQL_translator.git cd Eng_to_SQL_translator
-
Install dependencies:
pip install flask openai
-
Run the server:
python app.py
-
Open your browser and go to:
Input: Show me all customers who made a purchase in the last 30 days.
Output: SELECT * FROM customers WHERE purchase_date >= DATE_SUB(CURDATE(), INTERVAL 30 DAY);
---.
Built with ❤️ using:
- Flask: https://flask.palletsprojects.com/
- OpenAI GPT: https://platform.openai.com/
This project is licensed under the MIT License - see the LICENSE file for details.
Have suggestions or improvements? Feel free to open an issue or pull request!