Spaces:
Running on Zero
Download README.md from sagar312/Text-to-SQL: direct link, hf CLI and curl.
- Browser
- Download file 1.4 kB
-
https://huggingface.co/spaces/sagar312/Text-to-SQL/resolve/main/README.md
- Command line
-
hf download hf://spaces/sagar312/Text-to-SQL/README.md
-
curl -L -o README.md https://huggingface.co/spaces/sagar312/Text-to-SQL/resolve/main/README.md
A newer version of the Gradio SDK is available: 6.29.1
title: Text to SQL Demo
emoji: 🗃️
colorFrom: blue
colorTo: purple
sdk: gradio
sdk_version: 5.10.0
app_file: app.py
pinned: false
license: mit
Text-to-SQL Demo
Ask a plain-English question about a sample e-commerce database (customers, products, orders, order_items) and get back real, generated SQL plus the actual query results — retrieval, generation, AST validation, safe execution, and self-healing retries, all live.
This demo runs a fine-tuned Qwen2.5-3B model for SQL generation, paired
with a full retrieval-and-validation pipeline: hybrid schema retrieval
(dense + BM25) narrows down the relevant tables, an AST-level validator
enforces read-only, schema-checked queries before anything executes, and a
self-healing loop retries automatically if a query fails, feeding the
database's own error back to the model. Nothing but a validated SELECT
ever reaches the database, regardless of what the model generates.
Required Space secrets
Set these under Settings → Repository secrets before running:
| Secret | Example |
|---|---|
DB_HOST |
db.yourproject.supabase.co |
DB_PORT |
5432 |
DB_NAME |
postgres |
DB_USER |
postgres |
DB_PASSWORD |
(your database password) |
Point these at a read-only role on a database you're comfortable exposing publicly — this demo is configured for a small sample dataset, not production data.