|
Download README.md from ewdlop/Structured-Query-Language-Analyzer: direct link, hf CLI and curl.
- Browser
- Download file 2.64 kB
-
https://huggingface.co/spaces/ewdlop/Structured-Query-Language-Analyzer/resolve/main/README.md
- Command line
-
hf download hf://spaces/ewdlop/Structured-Query-Language-Analyzer/README.md
-
curl -L -o README.md https://huggingface.co/spaces/ewdlop/Structured-Query-Language-Analyzer/resolve/main/README.md
2.64 kB
| 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` | |