Skip to the content
Know your tech before you buy it. Makers: get listed from $49/mo

PgSanity

github.com

  • Free plan
  • Linux
  • Self-hosted
6.9 Club score Visit github.com

What PgSanity is

PgSanity is a free Python package that checks PostgreSQL SQL files for syntax errors. It wraps plain SQL in an embedded-SQL form and invokes ecpg, which uses PostgreSQL’s parser. You can provide one filename or several and receive errors with file and line information. Running it without filenames reads SQL from standard input, supporting interactive use and piping. The command exits with status 0 when syntax appears valid and 1 when errors are found, allowing scripts to react to the result. A pre-commit hook named pgsanity_lint is included for development workflows. PgSanity runs on Linux and self-hosted environments, supports the PostgreSQL dialect, and is installable from PyPI with pip or uv. It is also available through FreeBSD ports. Requirements include Python 3.9 or later and ecpg, with dependency package names listed for Ubuntu/Debian, RHEL/CentOS, and Arch. PyPI lists the MIT license and Mark Drago as sole maintainer and author.

Who it suits

PgSanity suits developers, IT professionals, and system administrators who need PostgreSQL syntax checks in files, pipelines, or pre-commit workflows.

Good to know, and what to watch

  • Checks one or multiple SQL files
  • Reads SQL from standard input
  • Reports file and line locations
  • Returns script-friendly exit codes
  • Includes a pre-commit hook
  • Requires Python 3.9 or later
  • Requires ecpg
  • Supports PostgreSQL SQL only
  • Linux and self-hosted use

Free

Free

Free plan

The verdict

PgSanity is a focused syntax checker for PostgreSQL SQL, with file, pipe, and pre-commit workflows. Its usefulness depends on having the required Python and ecpg dependencies available.

What the maker publishes

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

Checked against the maker's pages on 4 Oct 2026.