buildpg
Query building for the postgresql prepared statements and asyncpg.
Decision gist · record as of 2026-08-14
Yes, if you are using asyncpg and want to avoid manual string concatenation for parameterized queries, and you accept the maintenance risk. The package is stable and has no known vulnerabilities, but it is abandoned and will not adapt to breaking changes in asyncpg or Python. Use it for new projects only if you are comfortable pinning asyncpg and Python versions, or if you plan to fork and maintain it yourself.AI-flagged interpretation of the facts on this page — verify before relying
Before you install
- Requires asyncpg to be installed separately if using the asyncpg wrapper methods; PostgreSQL server required for actual query execution.
- Low install friction with no runtime dependencies.
- However, the package is abandoned—last release was 2022-03-01 and no commits since 2023-07-20.
License · maintenance · safety
MIT (permissive) — MIT license is permissive; you may use, modify, and distribute buildpg freely in proprietary or open-source projects with minimal restrictions.
last release 2022-03-01 (1627 days) · last repo commit 2023-07-20 · 87 stars
0 known vulnerabilities (OSV.dev, 2026-08-14) · 103,200 downloads/mo, #12,823 on PyPI
Alternatives
Verify before relying
from buildpg import render, V
sql, params = render('select * from mytable where x=:foo', foo=123)
# Returns: ('select * from mytable where x=$1', [123])
# With asyncpg wrapper:
import asyncio
from buildpg import asyncpg
async def query():
async with asyncpg.create_pool_b('postgres://localhost/db') as pool:
result = await pool.fetchval_b('select count(*) from t where id=:id', id=42)- Whether the package remains compatible with recent asyncpg versions (last tested with versions from early 2022).
- Whether Python 3.10+ support is confirmed despite classifiers listing only up to 3.9.
What it is and what it does
buildpg is a query builder that translates Python expressions into PostgreSQL prepared statements with parameter binding. It accepts named placeholders (`:foo`, `:bar`) in SQL strings and replaces them with positional parameters (`$1`, `$2`) suitable for asyncpg, while collecting the parameter values into a list. It also provides a `V()` wrapper for SQL identifiers and constants, allowing you to build complex WHERE clauses using Python operators (`&` for AND, `|` for OR, `==` for equality, etc.) and SQL functions like `funcs.count()`, `funcs.upper()`, and `funcs.position()`.
The package includes an optional asyncpg integration layer that wraps pool and connection methods with `*_b` variants (e.g., `fetch_b`, `fetchval_b`, `execute_b`) that accept buildpg-style named parameters and handle the rendering internally. It has no external runtime dependencies and installs as a pure Python wheel. However, the project is no longer maintained—the last release was in March 2022 and the repository has seen no commits since July 2023.
Use it for
- Build parameterized SELECT queries with dynamic WHERE clauses by combining V() objects with Python operators instead of string concatenation.
- Insert multiple rows using the Values() helper to generate column names and placeholders from keyword arguments.
- Construct complex conditionals programmatically—add AND/OR conditions only when certain flags are true, avoiding manual SQL string building.
- Wrap asyncpg pool operations to accept named parameters directly without manually calling render() before each query.
- Generate SQL with PostgreSQL-specific operators (contains @>, overlap &&, text search @@) using Python method calls on V() objects.
Worth the install?
AI-flagged interpretation of the facts on this page. Verify before relying on it.
Yes, if you are using asyncpg and want to avoid manual string concatenation for parameterized queries, and you accept the maintenance risk.
The package is stable and has no known vulnerabilities, but it is abandoned and will not adapt to breaking changes in asyncpg or Python. Use it for new projects only if you are comfortable pinning asyncpg and Python versions, or if you plan to fork and maintain it yourself.
Install
buildpg on PyPI
Before you install
Low install friction with no runtime dependencies. However, the package is abandoned—last release was 2022-03-01 and no commits since 2023-07-20. It remains functional for Python 3.7–3.9 but will not receive updates for breaking changes in asyncpg or Python itself.
Requires asyncpg to be installed separately if using the asyncpg wrapper methods; PostgreSQL server required for actual query execution.
License in practice
MIT license is permissive; you may use, modify, and distribute buildpg freely in proprietary or open-source projects with minimal restrictions.
Quickstart
from buildpg import render, V
sql, params = render('select * from mytable where x=:foo', foo=123)
# Returns: ('select * from mytable where x=$1', [123])
# With asyncpg wrapper:
import asyncio
from buildpg import asyncpg
async def query():
async with asyncpg.create_pool_b('postgres://localhost/db') as pool:
result = await pool.fetchval_b('select count(*) from t where id=:id', id=42)
Verify before relying
- Whether the package remains compatible with recent asyncpg versions (last tested with versions from early 2022).
- Whether Python 3.10+ support is confirmed despite classifiers listing only up to 3.9.
Package facts
| License | MIT permissive |
| Python support | Supports the current Python release >=3.6 |
| Install friction | Low. Pure-Python wheel |
| Runtime dependencies | None |
| Maintenance | Abandoned 1,627 days since the last release |
| Last repo commit | |
| First released | |
| Downloads | 103,200 / month, #12,823 on PyPI 30-day window, as of 2026-08-14 |
| Known vulnerabilities | None known OSV.dev, checked 2026-08-14 |
| Classifiers | Development Status :: 3 - AlphaEnvironment :: ConsoleEnvironment :: MacOS XIntended Audience :: DevelopersIntended Audience :: Information TechnologyIntended Audience :: System AdministratorsLicense :: OSI Approved :: MIT LicenseOperating System :: POSIX :: LinuxOperating System :: UnixProgramming Language :: PythonProgramming Language :: Python :: 3Programming Language :: Python :: 3 :: OnlyProgramming Language :: Python :: 3.7Programming Language :: Python :: 3.8Programming Language :: Python :: 3.9Programming Language :: SQLTopic :: InternetTopic :: Software Development :: Libraries :: Python Modules |
Evidence: buildpg-0.4-py3-none-any.whl
Tags
Let your AI agent find packages like this
Example. Real query, live index.
You found this page by searching. An agent finds it by wishing: SkillFed indexes 14,416 PyPI packages by what they can do, searchable in plain language.
wish › “asyncpg prepared statements”
- buildpgbuildpg constructs PostgreSQL prepared statements with named…
- asyncpgasyncpg is an asyncio-native PostgreSQL client library that executes…
- acsyllaAcsylla is an async Python client library for Cassandra and ScyllaDB…
Give your agent the search over MCP, or paste the wish link into any chat.
More Python Modules packages
Converts domain names between Unicode and ASCII-compatible encoding (Punycode) according to IDNA 2008 and Unicode Technical Standard 46, with security validation and broader script coverage than the standard library.
Install it if you work with internationalized domain names, need to validate domains, or use HTTP clients that depend on it transitively.
Setuptools is a Python build backend and package management tool that handles building, distributing, and installing Python packages, including support for C/C++ extension modules.
PyYAML parses and emits YAML 1.1 data format, enabling serialization and deserialization of configuration files and Python objects to and from human-readable YAML text.
Pydantic validates Python data structures against type hints, coercing and checking input at runtime to ensure it matches a declared schema.
Provides reusable metadata objects for use with PEP-593 `typing.Annotated` to express common constraints like bounds, collection sizes, and predicates on types.
Install it if you use or build libraries that need to express type constraints in a standardized, inspectable way—or if you want to annotate your own types with…
Provides runtime tools to inspect and introspect Python type annotations, enabling programmatic examination of type hints at execution time.
See also asyncpg · pgsanity · queries · django-query-builder · jinjasql2 · sqlparams · jinjasql · opentelemetry-instrumentation-asyncpg · asyncpg-trek · datafusion-query-builder