Skip to main content

SQL Diff Explainer

Explain the meaningful structural differences between two SQL SELECT queries.

The package uses sqlglot behind an abstract parser interface, so callers receive a stable result even if the parser implementation changes. It reports changes to projections, joins, filters, grouping, aggregation, ordering, pagination, and DISTINCT, with a static low/medium/high risk classification.

Development

This project uses a src/ layout and requires Python 3.10 or newer.

python -m venv .venv
.venv\Scripts\Activate.ps1
python -m pip install -e ".[dev]"
pytest

Library usage

from sql_diff_explainer import explain_sql_change

result = explain_sql_change(
    "SELECT department, COUNT(*) FROM employees GROUP BY department",
    "SELECT department, COUNT(*) FROM employees WHERE active = TRUE GROUP BY department",
)
print(result.to_dict())

explain_sql_change raises SQLParseError for invalid SQL and UnsupportedSQL for non-SELECT statements. Pass dialect="postgres" (or another sqlglot dialect) when parsing dialect-specific syntax.

CLI

sql-diff-explainer before.sql after.sql
sql-diff-explainer before.sql after.sql --dialect postgres --format json

JSON output is intended for CI and integrations; text output is optimized for human review. The process exits with status 2 for unreadable files or expected SQL errors.

Metadata

Release files for sql-diff-explainer 0.1.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for sql-diff-explainer 0.1.0
File Size Uploaded Provenance Actions
sql_diff_explainer-0.1.0.tar.gz 6.7 kB Without provenance Details for sql_diff_explainer-0.1.0.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for sql-diff-explainer 0.1.0
File Interpreter ABI Platform Actions
sql_diff_explainer-0.1.0-py3-none-any.whl Python 3 none any Details for sql_diff_explainer-0.1.0-py3-none-any.whl

Total release size: 13.9 kB

Release files / sql_diff_explainer-0.1.0.tar.gz

Download URL sql_diff_explainer-0.1.0.tar.gz
Size 6.7 kB
Tags Source
SHA-256 checksum
How to use checksums
a5fa9e4dbb5047242e71253afc7c8c2c84674c33176aefda20dafbdfc22f6c2e
BLAKE2b-256 checksum
How to use checksums
f1e03d48399c4053d8dfdbd3b1d3cffcacb0dfc85c800f56f300dc6e003023e0
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.14.7

Release files / sql_diff_explainer-0.1.0-py3-none-any.whl

Download URL sql_diff_explainer-0.1.0-py3-none-any.whl
Size 7.1 kB
Tags Python 3
SHA-256 checksum
How to use checksums
b0ce9f6a2c02db8715992c1aace4c25fc9515b368efea60f1f7eba23a1434e6a
BLAKE2b-256 checksum
How to use checksums
cdfe733c8eadccd8f10a9f517ec07435206dd03e0725e369cf79daf2246598c5
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.14.7

Security for sql-diff-explainer 0.1.0

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page