EVERYTHING XIAOMI
Get listed

PgSanity

PgSanity checks PostgreSQL SQL files for syntax errors using ecpg, which relies on PostgreSQL’s parser.

Place
#22 of 26
Score
5.7
PgSanity's website

What PgSanity is

PgSanity checks PostgreSQL SQL files for syntax errors using ecpg, which relies on PostgreSQL’s parser. It wraps SQL in an embedded-SQL form inside a C-like file before checking it. Provide one or more filenames to receive syntax errors with file and line details. If no filenames are supplied, PgSanity reads from standard input, allowing interactive use or input piped from another process. It returns status 0 when the syntax looks good and status 1 when it finds errors, so a workflow can respond to the result. The project includes a pre-commit hook called pgsanity_lint. It is a free Python package for Linux and self-hosted use, installable from PyPI using pip or uv and also available through FreeBSD ports. It requires Python 3.9 or later and ecpg; the README lists package names for Ubuntu/Debian, RHEL/CentOS, and Arch. The stated SQL dialect is PostgreSQL, and PyPI lists the license as MIT. The README directs users to GitHub to report problems, including incorrect syntax results.

Good

  • Reports syntax errors with file and line details
  • Can read SQL from standard input
  • Provides a pre-commit hook
  • Free and installable through pip or uv

Watch out

  • Requires Python 3.9 or later and ecpg
  • Supports PostgreSQL SQL only
  • Linux and self-hosted platforms are listed

Who it suits

PgSanity suits developers, IT professionals, and system administrators who want to check PostgreSQL SQL files in a command-line or pre-commit workflow.

Verdict

PgSanity offers a focused syntax check that can fit into file-based or standard-input workflows. Make sure Python and ecpg are available in the intended environment.

Plans and prices

From PgSanity's own pricing page, checked 4 Oct 2001.

All about pricing
PlanPriceWhat it gives you
FreeFreeOpen-source Python package · requires Python ≥3.9 and ecpg

The facts

Each one read from PgSanity's own pages, with the date it was checked.

What it does

Dependencies
The stated dependencies are Python 3.9 or later and ecpg; the README lists package names for Ubuntu/Debian, RHEL/CentOS, and Arch.checked 4 Oct 2001
Distribution
The project is installable from PyPI with pip or uv and is also available through FreeBSD ports.checked 4 Oct 2001
Exit codes
It exits with status 0 when SQL syntax looks good and 1 when errors are found.checked 4 Oct 2001
File input
It accepts one or multiple filenames and reports syntax errors with file and line information.checked 4 Oct 2001
How it works
It wraps bare SQL as embedded SQL in a C-like file and uses ecpg, which uses PostgreSQL’s parser, to report syntax errors.checked 4 Oct 2001
Intended audience
PyPI classifies the intended audience as developers, information technology, and system administrators.checked 4 Oct 2001
License
PyPI lists the project’s license expression as MIT.checked 4 Oct 2001
Maintainer
PyPI lists Mark Drago as the project’s sole maintainer and author.checked 4 Oct 2001
Purpose
PgSanity checks the syntax of PostgreSQL SQL files.checked 4 Oct 2001
Security reporting
The README directs users to report problems, including incorrect syntax results, through the GitHub repository.checked 4 Oct 2001
Standard input
When no filenames are provided, it reads SQL from stdin for interactive use or piping.checked 4 Oct 2001
Support
The README points users to the GitHub project page to report problems.checked 4 Oct 2001
Workflow integration
The repository provides a pre-commit hook with the id pgsanity_lint.checked 4 Oct 2001

Alternatives to PgSanity

All alternatives
  1. 1

    Poor SQL

    Free planOpen sourceWebAPIExtensionLinux
    7.3Free plan
  2. 2

    SQLFormat.org

    Free planOpen sourceWebAPIExtensionSelf-hosted
    7.1Free plan
  3. 3

    sqlfmt

    Free planWebAPILinuxSelf-hosted
    6.7Free plan
  4. 4

    RegSQL

    Free planWeb
    6.5From $8 a month
  5. 5

    SQLCheck

    Free planLinuxmacOSWindows
    6.5Free plan
  6. 6

    sqlfmt

    Free planWebAPI
    6.5From $9 a month