Skip to main content

pglast

PostgreSQL Languages AST and statements prettifier

Author:

Lele Gaifax

Contact:

lele@metapensiero.it

License:

GNU General Public License version 3 or later

Status:

Build status Documentation status

Version:

8

This is a Python 3 module that exposes the parse tree of a PostgreSQL statement (extracted by the almost standard PG parser repackaged as a standalone static library by libpg_query) as set of interconnected nodes, usually called an abstract syntax tree.

See a more detailed introduction in the documentation.

Installation

As usual, the easiest way is with pip:

$ pip install pglast

Alternatively you can clone the repository:

$ git clone https://github.com/lelit/pglast.git --recursive

and install from there:

$ pip install ./pglast

Development

There is a set of makefiles implementing the most common operations, a make help will show a brief table of contents. A comprehensive test suite, based on pytest, covers nearly 99% of the source lines.

Contributing

Many of the sources in this repository are mechanically derived from others: the enums, the keyword sets, the pglast.ast module and its type stubs, the printer documentation and the parser.c translation are all produced by one of the tools in tools/, driven by the Makefile. Each of those files carries a DO NOT EDIT notice in its header, and none of them should ever be modified by hand: change the generating tool, its input data or the recipe, then rebuild with make build.

Because a tiny change in a generator can produce an avalanche of changes in its output, two developers working on unrelated areas of the same generator will rarely conflict on the generator itself, but are bound to conflict on the generated sources when their branches are merged. A handful of lines edited in one of the tools is enough to rewrite every file it produces: skipping a few node definitions in tools/extract_ast.py, for instance, was followed by a regeneration touching more than twenty thousand lines, spread over the pglast.ast module, the enums, the keyword sets and parser.c. The trigger can also come from outside the tools: bumping libpg_query affects nearly all of the generated files, since its revision is embedded in a comment of most of them, and a new release of Cython retranslates parser.c from scratch. In all those cases use “Update generated sources” as the subject of the regeneration commit, or “Regenerate with Cython X.Y.Z” when that is what triggered it, and do not let it carry any other modification.

Also, I try to maintain the two most recent major versions of pglast: when a defect affects also the previous version, please target that first.

Documentation

Latest documentation is hosted by Read the Docs at https://pglast.readthedocs.io/en/v8

Metadata

Release files for pglast 8.9

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

Source distribution (sdist)

Source distribution for pglast 8.9
File Size Uploaded Provenance Actions
pglast-8.9.tar.gz 4.1 MB Without provenance Details for pglast-8.9.tar.gz

Release files / pglast-8.9.tar.gz

Download URL pglast-8.9.tar.gz
Size 4.1 MB
Tags Source
SHA-256 checksum
How to use checksums
d99df8cbe4a5902c193be31eebc04c08602766379a61c3d7fc5f9bb74986e450
BLAKE2b-256 checksum
How to use checksums
f121de733535c819287b267f16cd63b59c5d10f8934e12d79f4921d4be2e5bbb
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.14.10

Security for pglast 8.9

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