ewdlop's picture
fix: shorten short_description for Hugging Face validation
f277149
---
title: SQL Analyzer
emoji: πŸ”
colorFrom: blue
colorTo: indigo
sdk: docker
pinned: false
short_description: "SQL analyzer: linter, AST explorer, formatter & detector"
---
# SQL Analyzer β€” Linter, AST Explorer & Injection Detector
An interactive SQL analysis tool powered by **SQLFluff 4.x**, built as a pure Python FastAPI backend serving a React frontend.
## Features
- **SQL Linter** β€” SQLFluff rule violations with severity, rule codes, line/column info, and fixable indicators
- **AST Tree Explorer** β€” Interactive collapsible/expandable parse tree with search, filter, and color-coded node types
- **SQL Injection Detector** β€” Detects tautologies, stacked queries, UNION exfiltration, comment bypasses, and more
- **SQL Formatter** β€” Auto-fix and format SQL with copy-to-clipboard and apply-to-editor
- **Swagger UI** β€” Full OpenAPI 3.1 documentation at `/swagger`
- **17 SQL dialects** β€” ANSI, PostgreSQL, MySQL, T-SQL, SQLite, BigQuery, Snowflake, Redshift, DuckDB, Hive, Spark SQL, Trino, Databricks, Oracle, Teradata, ClickHouse, Athena
## Architecture
```
sql-analyzer-standalone/
β”œβ”€β”€ api/
β”‚ β”œβ”€β”€ main.py ← FastAPI app (REST endpoints + static file serving)
β”‚ └── static/ ← Built React bundle (generated by pnpm build)
β”œβ”€β”€ frontend/
β”‚ β”œβ”€β”€ src/ ← React 19 + TypeScript source
β”‚ β”œβ”€β”€ package.json
β”‚ └── vite.config.ts ← Builds into ../api/static/
β”œβ”€β”€ requirements.txt
β”œβ”€β”€ Dockerfile
└── README.md
```
## Local Development
```bash
# 1. Install Python deps
pip install -r requirements.txt
# 2. Build the React frontend
cd frontend && pnpm install && pnpm build && cd ..
# 3. Start the FastAPI server
cd api && uvicorn main:app --reload --port 7860
```
Open http://localhost:7860
## API Endpoints
| Method | Path | Description |
|--------|------|-------------|
| GET | `/api/health` | Health check + SQLFluff version |
| POST | `/api/lint` | Lint SQL with SQLFluff |
| POST | `/api/parse` | Parse SQL into AST |
| POST | `/api/format` | Format/fix SQL |
| POST | `/api/inject` | Detect SQL injection patterns |
| GET | `/openapi.json` | OpenAPI schema |
| GET | `/docs` | Swagger UI (FastAPI built-in) |
| GET | `/swagger` | Custom Swagger UI page |
## Request Format
All POST endpoints accept:
```json
{
"sql": "SELECT * FROM users WHERE id = 1",
"dialect": "ansi"
}
```
Supported dialects: `ansi`, `postgres`, `mysql`, `tsql`, `sqlite`, `bigquery`, `snowflake`, `redshift`, `duckdb`, `hive`, `sparksql`, `trino`, `databricks`, `oracle`, `teradata`, `clickhouse`, `athena`