A Streamlit web app that converts natural language business questions into SQL queries, executes them on a MySQL database, and displays the results. Powered by Azure OpenAI and Azure Cognitive Search.
- Ask business questions in plain English.
- Automatically generates SQL queries using Azure OpenAI.
- Executes queries on a MySQL database and displays results.
- Uses Azure Cognitive Search for schema-aware context (RAG).
- Modern, responsive UI with Streamlit.
app.py— Main Streamlit app.text_to_sql.py— Converts questions to SQL using Azure OpenAI and Azure Search.database.py— Handles MySQL connection and query execution.create_and_upload_index.py— Creates and uploads schema info to Azure Search.data/— Contains CSVs and schema SQL for the sample database..env— Environment variables for API keys and DB credentials.requirements.txt— Python dependencies.
git clone <your-repo-url>
cd sql_assistant_by_aaitechpip install -r requirements.txt- Copy
.envand fill in your Azure OpenAI, Azure Search, and MySQL credentials.
python create_and_upload_index.pystreamlit run app.py- Open the Streamlit app in your browser.
- Enter a business question (e.g., "Show total orders by country").
- View the generated SQL and query results.
- Python 3.8+
- MySQL server
- Azure OpenAI and Azure Cognitive Search accounts
MIT License
