File size: 2,636 Bytes
fde182b 42ae0b9 fde182b f277149 fde182b 42ae0b9 | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 | ---
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`
|