$npx skillfedfor your agent

pgsanity

Check syntax of sql for PostgreSQL

With conditionsPyPI UtilitiesReleased Sep 2025537.5K downloads / moMITPure Python

Decision gist · record as of 2026-08-14

pure-Python wheel — pgsanity-0.3.0-py3-none-any.whl
v0.3.0 · released 2025-09-20 · Python >=3.9

Yes, if you need PostgreSQL SQL syntax validation in CI/CD or pre-commit workflows and have ecpg available on your system. The package is lightweight, permissively licensed, and well-integrated with Unix tooling. The aging maintenance status is not a blocker for a stable, narrow-purpose tool, but verify that ecpg is available in your deployment environment before committing to it.AI-flagged interpretation of the facts on this page — verify before relying

Before you install

  • ecpg must be installed on your system (Ubuntu/Debian: libecpg-dev, RHEL/CentOS: postgresql-devel, Arch: postgresql-libs).
  • Python >= 3.9 required.
  • Low friction: pure Python wheel with no runtime dependencies.

License · maintenance · safety

MIT (permissive) — MIT license permits unrestricted use, modification, and distribution with minimal obligations, making it safe for commercial and proprietary projects.

last release 2025-09-20 (328 days) · last repo commit 2025-09-20 · 325 stars

0 known vulnerabilities (OSV.dev, 2026-08-14) · 537,526 downloads/mo, #6,119 on PyPI

Verify before relying

pip install pgsanity

pgsanity file_with_sql.sql

echo "select mycol from mytable;" | pgsanity
  • Whether ecpg availability varies significantly across operating systems beyond the documented package managers
  • How error line reporting accuracy compares to other PostgreSQL syntax validators
  • Whether the package handles all PostgreSQL dialect variants or only a subset
Same gist for agents: .md · .json

What it is and what it does

PgSanity is a command-line tool and Python package that checks PostgreSQL SQL files for syntax errors. It works by converting SQL into a C file with embedded SQL, then running it through the ecpg preprocessor—the same parser PostgreSQL uses internally—to catch syntax problems before deployment. The tool accepts filenames as arguments, reads from stdin if none are provided, and exits with status 0 for valid SQL or 1 when errors are found.

The package requires ecpg (part of PostgreSQL development libraries) to be installed on your system, plus Python 3.9 or later. It integrates well with Unix pipelines and find/xargs workflows, and can be used as a pre-commit hook for automated validation in version control. Error messages come directly from ecpg and include line numbers, though the reported line may point to the statement after the actual error.

Use it for

  • Validate SQL files in CI/CD pipelines before deployment to catch syntax errors early
  • Use as a pre-commit hook to prevent malformed SQL from being committed to version control
  • Batch-check multiple SQL files with find and xargs to audit a codebase for syntax problems
  • Integrate into development workflows to catch typos and dialect mismatches interactively via stdin
  • Enforce SQL standards in teams by running validation on all .sql files in a repository

Worth the install?

AI-flagged interpretation of the facts on this page. Verify before relying on it.

With conditions

Yes, if you need PostgreSQL SQL syntax validation in CI/CD or pre-commit workflows and have ecpg available on your system.

The package is lightweight, permissively licensed, and well-integrated with Unix tooling. The aging maintenance status is not a blocker for a stable, narrow-purpose tool, but verify that ecpg is available in your deployment environment before committing to it.

Install

pgsanity on PyPI

Before you install

Low friction: pure Python wheel with no runtime dependencies. Maintenance is aging—last release was 328 days ago—but the repository remains active with recent commits and no archived status.

ecpg must be installed on your system (Ubuntu/Debian: libecpg-dev, RHEL/CentOS: postgresql-devel, Arch: postgresql-libs). Python >= 3.9 required.

License in practice

MIT license permits unrestricted use, modification, and distribution with minimal obligations, making it safe for commercial and proprietary projects.

Quickstart

pip install pgsanity

pgsanity file_with_sql.sql

echo "select mycol from mytable;" | pgsanity

Verify before relying

  • Whether ecpg availability varies significantly across operating systems beyond the documented package managers
  • How error line reporting accuracy compares to other PostgreSQL syntax validators
  • Whether the package handles all PostgreSQL dialect variants or only a subset

Package facts

LicenseMIT permissive
Python supportSupports the current Python release >=3.9
Install frictionLow. Pure-Python wheel
Runtime dependenciesNone
MaintenanceAging 328 days since the last release
Last repo commit
First released
Downloads537,526 / month, #6,119 on PyPI 30-day window, as of 2026-08-14
Known vulnerabilitiesNone known OSV.dev, checked 2026-08-14
Classifiers
Development Status :: 4 - BetaIntended Audience :: DevelopersIntended Audience :: Information TechnologyIntended Audience :: System AdministratorsLicense :: OSI Approved :: MIT LicenseOperating System :: POSIXProgramming Language :: Python :: 3Topic :: DatabaseTopic :: Database :: Database Engines/ServersTopic :: Software Development :: Quality AssuranceTopic :: Software Development :: TestingTopic :: Utilities

Evidence: pgsanity-0.3.0-py3-none-any.whl

Tags

Capabilities
postgresql sql syntax checkersql linter postgresvalidate sql filespostgres sql validationpre-commit sql lintingecpg syntax checkersql error detection
Topics
sql-lintingpostgresci-cd
PyPI keywords
pgsanitysqlsyntaxpostgresqlpostgres

Let your AI agent find packages like this

Example. Real query, live index.

You found this page by searching. An agent finds it by wishing: SkillFed indexes 14,416 PyPI packages by what they can do, searchable in plain language.

wish › “postgresql sql syntax checker”

  • pgsanityPgSanity validates PostgreSQL SQL syntax by wrapping the ecpg parser,…
  • squawk-cliLinter that analyzes PostgreSQL migrations and SQL statements to…
  • pglastParses PostgreSQL SQL statements into an abstract syntax tree and…

Give your agent the search over MCP, or paste the wish link into any chat.

More Utilities packages

idna Worth it
PyPI · Python Modules · released Jun 2026

Converts domain names between Unicode and ASCII-compatible encoding (Punycode) according to IDNA 2008 and Unicode Technical Standard 46, with security validation and broader script coverage than the standard library.

Install it if you work with internationalized domain names, need to validate domains, or use HTTP clients that depend on it transitively.

BSD-3-Clausepure Python · 3.9+
1.8Bdownloads / mo
charset-normalizer Worth it
PyPI · Utilities · released Aug 2026

Detects and normalizes text encoding from unknown or ambiguous sources, supporting all IANA character sets that Python's core library provides codecs for, with the ability to register custom codecs.

permissive licensepure Python · 3.7+
1.7Bdownloads / mo
setuptools Worth it
PyPI · Python Modules · released Aug 2026

Setuptools is a Python build backend and package management tool that handles building, distributing, and installing Python packages, including support for C/C++ extension modules.

MITpure Python · 3.10+
1.6Bdownloads / mo
pluggy Worth it
PyPI · Libraries · released May 2025

Pluggy provides a plugin system that lets you define hook specifications and register implementations to be called in sequence, enabling extensible Python applications without tight coupling.

Install it if you're building an extensible application or framework.

MITpure Python · 3.9+aging
1.3Bdownloads / mo
Pygments Worth it
PyPI · Utilities · released Mar 2026

Pygments is a syntax highlighter that colorizes source code and text in over 500 languages and formats, outputting to HTML, LaTeX, RTF, SVG, images, or ANSI terminal sequences.

Install it if you need to display or transform source code.

BSD-2-Clausepure Python · 3.9+
1.3Bdownloads / mo
six With conditions
PyPI · Libraries · released Dec 2024

Six provides utility functions to write Python code that runs on both Python 2.7 and Python 3.3+, smoothing over language differences between the two versions.

MITpure Python
1.2Bdownloads / mo

See also buildpg · pglast · sql-formatter · pytest-pgsql · squawk-cli · pgspecial · pgcli · pgdb · testing.postgresql · pipestat