PyPgConfig
Access pg_config from Python
What it is and what it does
PyPgConfig is a thin Python wrapper around the PostgreSQL pg_config utility. It runs pg_config on the system and parses its output to expose PostgreSQL metadata—version number (with major/minor breakdown), linked libraries, and build-time options like Python support—as Python objects and attributes.
The package is useful when you need to programmatically discover PostgreSQL installation details at runtime, such as which libraries PostgreSQL was compiled with or whether Python support is enabled. It requires that PostgreSQL and pg_config be installed on the system where the code runs.
Use it for:
- Detect PostgreSQL version at runtime to conditionally enable or disable features in a Python application.
- Query which libraries PostgreSQL was compiled with to verify compatibility before attempting a connection.
- Locate the Python installation path that PostgreSQL was built with to ensure consistent Python environments.
- Automate build or deployment scripts that need to confirm PostgreSQL is installed and inspect its configuration.
- Validate PostgreSQL build options (e.g., Python support) before initializing a database client.
Worth the install?
AI-flagged interpretation of the facts on this page — verify before relying
PyPgConfig detects and exposes PostgreSQL configuration details from the system's pg_config tool, allowing Python code to query PostgreSQL version, library dependencies, and build settings.
Yes, if you need to programmatically query PostgreSQL configuration at runtime and can accept an alpha-stage, dormant package. The low install friction and permissive license are in its favor, and there are no known vulnerabilities. However, the lack of updates since 2023-11-28 and alpha status mean you should verify it works with your PostgreSQL version and be prepared to maintain a fork if needed.
Install
pypgconfig on PyPI
pip
pip install pypgconfiguv
uv add pypgconfigpoetry
poetry add pypgconfigInstalling PyPgConfig
Before you install
Installation is straightforward with low friction—the package is a pure Python wheel with only setuptools and pip as runtime dependencies. However, the project is dormant; the last commit was 2023-11-28 and no updates have been released since the initial 0.1.0a2 alpha version.
License in practice
Licensed under Apache License, Version 2.0 (permissive), so you may use, modify, and distribute the package freely in commercial and private projects, provided you include a copy of the license.
Quickstart
pip install PyPgConfig
from pypgconfig import detect
pgconf = detect()
pgconf.version # "15.4"
pgconf.libs # ["pgcommon", "pgport", "lz4", "xml2"]
PostgreSQL and pg_config must be installed on the system where this code runs.
Verify before relying
- Whether detect() raises an exception or returns a specific value if pg_config is not found.
- Whether the package works with PostgreSQL versions other than the 15.4 example shown.
- Stability guarantees for the 0.1.0a2 alpha release and whether a stable 1.0 is planned.
Package facts
| License | Apache License, Version 2.0 (permissive) |
| Python support | supports the current Python release (>=3.7) |
| Install friction | low — pure-Python wheel |
| Runtime dependencies | 2 — setuptools, pip |
| Maintenance | dormant — 991 days since the last release |
| Last repo commit | |
| First released | |
| Downloads | 98,966/month — #13,046 on PyPI (30-day window, as of 2026-08-14) |
| Known vulnerabilities | none known (OSV.dev, checked 2026-08-14) |
Evidence: PyPgConfig-0.1.0a2-py3-none-any.whl
Tags
More Database packages
psycopg2-binary is a PostgreSQL database…
copyleft · top 1,000 on PyPI
redisPython client library for connecting to and…
permissive · top 1,000 on PyPI
ydbYDB Python SDK is the official client library…
permissive · top 1,000 on PyPI
snowflake-connector-pythonConnects Python applications to Snowflake data…
permissive · top 1,000 on PyPI
sqlparsesqlparse tokenizes SQL text into a tree of…
permissive · top 1,000 on PyPI
dbt-adaptersProvides base adapter protocols and shared…
permissive · top 1,000 on PyPI
pgdbWraps PostgreSQL connections to return query…
permissive · top 15,000 on PyPI
py-pglitepy-pglite provides a zero-config PostgreSQL…
permissive · top 15,000 on PyPI
psycopgPsycopg 3 is a PostgreSQL database adapter for…
copyleft · top 1,000 on PyPI
pgserverEmbeds a PostgreSQL server with pgvector…
unclear · top 15,000 on PyPI
aws-psycopg2Provides psycopg2 with statically linked…
permissive · top 5,000 on PyPI
testing.postgresqlAutomatically creates and tears down temporary…
permissive · top 5,000 on PyPI
detect-installerDetects which package manager installed a given…
permissive · top 5,000 on PyPI
postgresProvides a lightweight abstraction layer over…
permissive · top 15,000 on PyPI
pg0-embeddedEmbeds a PostgreSQL database directly in Python…
permissive · top 15,000 on PyPI
findpythonLocates Python interpreters on your system by…
permissive · top 1,000 on PyPI