A web-based application that converts natural language questions into SQL queries and executes them against SQLite databases.
- Natural language to SQL query conversion
- SQLite database connection and schema analysis
- Query execution with result display
- Conversation history tracking
- Sample database creation for testing
- Direct SQL query execution interface
Core Dependencies:
- Clone the repository
- Install dependencies:
pip install pandas langchain-core langchain-ollama gradio
- Ensure Ollama is installed and running with the deepseek-coder model:
ollama pull deepseek-coder:6.7b
python app.py
The application will launch in your web browser at http://localhost:7860
- Upload a SQLite database file (.db, .sqlite, .sqlite3)
- Or create a sample e-commerce database for testing
Submit questions in natural language through the Query Interface:
- "Show all customers from USA"
- "List top 5 products by sales"
- "Find orders over $500"
Use the SQL Executor tab to run custom SQL queries directly against the connected database.
The application uses the deepseek-coder:6.7b
model by default. To change the model:
app = TextToSQLApp(model_name="your-preferred-model")
The application can generate a sample e-commerce database with the following tables:
customers
- Customer informationproducts
- Product catalogorders
- Order recordsorder_items
- Order line items
- Supports SQLite databases only
- Requires Ollama runtime with compatible language models
- Query complexity depends on model capabilities
- No authentication or user management
- Backend:
with
for LLM integration
- Database:
with
for data handling
- Frontend:
web interface
- LLM:
compatible models for SQL generation
The application includes error handling for:
- Database connection failures
- Invalid SQL syntax
- Missing database schema
- Model communication errors