skillfed

pgspecial

Meta-commands handler for Postgres Database.

pgspecial v2.2.1 650.5K downloads/30d#5,561 on PyPI
Permissive license BSD AGING released

What it is and what it does

pgspecial is a Python library that wraps PostgreSQL's meta-commands—the backslash commands you'd normally type in psql—into a callable API. It lets you execute commands programmatically against a live database connection, returning structured results you can process in code.

The library is designed for tools that need to expose PostgreSQL introspection and administration commands without reimplementing them. It depends on click, sqlparse, and psycopg for the database connection itself. You instantiate PGSpecial, pass it a cursor and a command string, and iterate over the results. It also supports loading named queries from config files via the NamedQueries class.

Use it for:

  • Building a PostgreSQL REPL or interactive shell that supports backslash commands.
  • Adding database introspection to a Jupyter notebook or IPython environment.
  • Implementing a web-based database management tool that needs to expose PostgreSQL admin commands.
  • Automating database inspection tasks in scripts without reimplementing meta-command logic.

Worth the install?

AI-flagged interpretation of the facts on this page — verify before relying

Executes PostgreSQL meta-commands (backslash commands) programmatically through a Python API, enabling applications to run special commands on a database connection.

Yes, if you need to execute PostgreSQL meta-commands programmatically. The library is stable, has low install friction, carries a permissive license, and is actively used by established projects. The 473-day release gap is a minor concern for a mature, narrow-scope package, but verify compatibility with your PostgreSQL and psycopg versions before production use.

Install

pgspecial on PyPI

pip

pip install pgspecial

uv

uv add pgspecial

poetry

poetry add pgspecial

Installing pgspecial

Before you install

Low friction installation with three lightweight runtime dependencies. Maintenance status is aging—last release was 473 days ago—but the package remains in use by established projects.

License in practice

BSD permissive license allows use in commercial and proprietary projects with minimal restrictions, requiring only license attribution.

Quickstart

pip install pgspecial

from pgspecial.main import PGSpecial

pgspecial = PGSpecial()
for result in pgspecial.execute(cur, sql):
    print(result)

Requires Python >=3.9 and an active psycopg database connection.

Verify before relying

  • Whether the 473-day gap since last release reflects stable maturity or abandonment risk for future PostgreSQL compatibility.
  • Current state of the repository (archived status, recent commits) to assess ongoing maintenance.
  • Compatibility with current versions of psycopg and PostgreSQL.

Package facts

License BSD (permissive)
Python support supports the current Python release (>=3.9)
Install friction low — pure-Python wheel
Runtime dependencies 3 — click, sqlparse, psycopg
Maintenance aging — 473 days since the last release
First released
Downloads 650,487/month — #5,561 on PyPI (30-day window, as of 2026-08-14)
Known vulnerabilities none known (OSV.dev, checked 2026-08-14)

Evidence: pgspecial-2.2.1-py3-none-any.whl

Keywords: postgres, database, cli, meta-commands

Tags

postgres meta-commandspostgresql backslash commandspostgres special commands apipgspecial postgresdatabase introspectionpostgres repl commands
postgres-clidatabase-introspection

More Front-Ends packages