A Streamlit web application that converts natural-language business questions into safe, read-only SQLite queries using a local Hugging Face transformer model.
- Connects dynamically to any SQLite database and extracts schema.
- Uses Hugging Face
transformersto generate SQL from natural language. - Strictly validates generated SQL for read-only safety (blocks
INSERT,UPDATE,DROP, multi-statement, etc.). - Clean Streamlit UI with query history, settings, and result display.
Make sure you have Python 3.11 installed. Create a virtual environment and install the requirements:
python -m venv venv
# On Windows:
venv\Scripts\activate
# On Linux/Mac:
source venv/bin/activate
pip install -r requirements.txtCreate a .env file in the root directory (or rename .env.example to .env) and update the paths:
# Hugging Face Model ID (e.g. "budecosystem/sql-millennials-13b")
# Or an absolute local path to your model folder
MODEL_ID_OR_PATH="budecosystem/sql-millennials-13b"
# Absolute path to your SQLite database
DATABASE_PATH="REPLACE_WITH_MY_SQLITE_DB"Start the Streamlit server:
streamlit run app.py- The application currently supports SQLite only.
- Designed for small/medium local transformer models. Ensure you have adequate RAM/VRAM for the model you specify.
- V1 does not include user authentication or containerization.
- "Show total sales by month"
- "How many users signed up last week?"
- "List the top 5 products by revenue"