SayQL Live Demo here
A local-first Natural Language to SQL application for PostgreSQL healthcare facility data.
- FastAPI backend
- PostgreSQL metadata inspection
- SQLAlchemy connection pooling
- Configurable Ollama or OpenRouter SQL generation
- Read-only query execution
- schema and SQL validation layers
-
Create a virtual environment: python -m venv .venv source .venv/bin/activate
-
Install dependencies: pip install -r requirements.txt
-
Copy environment file: cp .env.example .env
-
Update database and LLM settings in
.envif needed. SetLLM_PROVIDER=openrouterand provideOPENROUTER_API_KEYto use OpenRouter. -
Run the app: uvicorn app.main:app --reload
- GET /
- GET /health
- GET /api/schema
- POST /api/query
- POST /api/rawQuery
Example request:
{
"question": "How many facilities are there in each district?"
}This project is intentionally lightweight and uses direct SQLAlchemy and HTTP LLM integrations without LangChain or LlamaIndex.