SQL Risk Checker (Free)

Catch the DELETE that was meant to have a WHERE before anyone runs it.

SQL Risk Checker (Free) cover

What it does

Catch the DELETE FROM orders; that was meant to have a WHERE before anyone runs it. The checker reads .sql files, folders or a pasted snippet. It flags statements that change or delete a lot of data, plus a few query bugs that quietly return wrong results. Runs on your computer, in pre-commit, or as GitHub pull-request annotations. Python standard library only; it never connects to a database.

$ python3 -m sqlrisk examples/cleanup.sql
examples/cleanup.sql: 10 statements (3 block, 4 confirm, 0 write, 3 read)
  BLOCK   line 5    DELETE with no WHERE changes every row: DELETE FROM staging.events
  BLOCK   line 6    UPDATE with no WHERE changes every row: UPDATE crm.accounts SET owner_id = 42 WHERE 1=1
  ERROR   line 9    EQUALS_NULL: = NULL / != NULL is never true; use IS NULL / IS NOT NULL
  BLOCK   line 14   DROP SCHEMA deletes everything in it: DROP SCHEMA scratch CASCADE
  ...
FAIL (fail-on block)

What you get

The screenshot is real output from the kit’s own commands. Tested from a fresh download of this exact zip: ./run_tests.sh ran 7 tests OK on Python 3.13 and 3.10.

Real terminal output from SQL Risk Checker: demo and passing tests

Levels

LevelStatements
blockDROP DATABASE / SCHEMA; DELETE or UPDATE with no WHERE, or with WHERE 1=1 / WHERE TRUE
confirmDROP TABLE/VIEW/COLUMN..., TRUNCATE, ALTER, GRANT/REVOKE, DELETE/UPDATE with a WHERE, MERGE, INSERT OVERWRITE, CREATE OR REPLACE TABLE
writeINSERT, COPY, CREATE, CALL, VACUUM and other writes
readeverything else

Lint checks: = NULL (never true), NOT IN (SELECT ...) (no rows if the subquery has a NULL), comma joins (accidental cross joins) and SELECT *. Comments, strings and $$ bodies are ignored, so 'DROP TABLE x' inside a string is not flagged. Works with PostgreSQL, MySQL, SQLite, Snowflake, BigQuery, Databricks and similar dialects.

Options

  • --fail-on block (default), confirm, error (block plus = NULL) or never. Exit 1 when something at that level is found.
  • --format text|json|github. github prints annotations that GitHub shows on the pull request.
  • Put -- sqlrisk: ignore on the line above a statement a person has reviewed (for example a one-time backfill). It is still listed, but it doesn't fail.

In CI and pre-commit

Copy sqlrisk/ to your repository root, then:

  • GitHub Actions: copy ci/.github/workflows/sqlrisk.yml. Pull requests that touch .sql files get annotations, and the check fails on block-level statements.
  • pre-commit: merge ci/.pre-commit-config.yaml (a local hook that runs on staged .sql files).

./demo.sh runs both output modes on the examples. ./run_tests.sh runs the tests. It's also a Claude Code plugin with a skill in skills/sql-risk/.

The checker reads text only. It doesn't know your data, row counts or permissions, so a person still decides whether a confirm-level statement is intended.

Working with data in Claude Code? Data & Analytics Subagents adds 10 subagents (SQL review, query tuning, dbt, data quality, metrics, A/B tests). It also has a guard hook that stops Claude from running DELETE without WHERE or DROP SCHEMA through psql, bq, snowsql and other database CLIs: https://youraitools.co/marketplace/data-analytics-subagents

Honest limits

  • The checker reads text only.
  • It doesn't know your data, row counts or permissions, so a person still decides whether a confirm-level statement is intended.

Format and license

Zip, 13 KB, v1.0, 16 files. Free to use, modify and share for any purpose, including commercial work, as long as this notice stays in copies. Not affiliated with or endorsed by any database vendor.

FAQ

Is it free?
Yes, enter your email for the newsletter or download directly.
Does it connect to my database?
No, it reads SQL text only.
Which databases?
PostgreSQL, MySQL, SQLite, Snowflake, BigQuery, Databricks and similar dialects.
How do I get the files?
Click Download free. The zip downloads straight away: no checkout, no account.
Do I have to sign up for the newsletter?
No. The form is optional and the download works without it.

Get SQL Risk Checker (Free)

Free SQL checker: flags DELETE/UPDATE without WHERE, DROP, TRUNCATE and query bugs like = NULL. Command line, GitHub Actions annotations and pre-commit.

Pairs well with

Download$19

CSV Compare & Reconcile Skill

Compare two CSV files by key: added, removed and changed cells with % change, format-only differences ignored. Reconcile invoice and payment totals. Local tool.

View CSV Compare & Reconcile Skill
Download$19

Org Chart Builder Skill

Create an org chart from a CSV or HRIS export: HTML, Mermaid, draw.io and Graphviz. Finds missing managers, reporting loops and duplicate IDs. Runs locally.

View Org Chart Builder Skill
Download$119

Agent Builder Bundle

Swarm Operator Kit + x402 Builder Skills + MCP Starter Kit. $119 instead of $157.

View Agent Builder Bundle

Related