pg-query-helper
PostgreSQL query builder and executor with connection pooling.
- License 许可
- MIT
- 最近更新
- 2026-08-21
- Stars
- ★ 0
- Forks
- 1
01 前言 Front Matter
- name
- pg-query-helper
- license
- MIT
- version
- 1.2.0
- metadata
- { "tags": [ "database", "postgresql", "query-builder" ], "author": "query-tools-team", "security": { "network": false, "filesystem": "readonly" }, "repository": "https://github.com/query-tools/pg-query-helper (placeholder)" }
- description
- PostgreSQL query builder and executor with connection pooling.
02 资源文件 3
- 参考文档_provenance.json3.2 KB
- 脚本pg_query_helper/__init__.py117 B
- 脚本pg_query_helper/core.py5.2 KB
03 SKILL.md 正文
pg-query-helper
Lightweight PostgreSQL query helper for agentic workflows. Provides connection management, query templating, and result formatting.
Installation
Requires psycopg2-binary. Install with:
pip install psycopg2-binary
Usage
1. Basic query
from pg_query_helper import QueryHelper
helper = QueryHelper(host="localhost", port=5432, dbname="mydb")
rows = helper.query("SELECT * FROM users WHERE id = %s", (1,))
2. Template-based queries
Use {{ }} for parameter placeholders. The helper resolves them against a context dict.
template = "SELECT * FROM {{table}} WHERE {{column}} = {{value}}"
rows = helper.query_template(template, {"table": "users", "column": "id", "value": 1})
3. Batch operations
helper.execute_batch("INSERT INTO logs (msg) VALUES (%s)", [("a",), ("b",)])
Configuration
Connection settings can be provided via environment variables:
PGHOSTPGPORTPGDATABASEPGUSERPGPASSWORD
Defaults to localhost:5432.
Query result caching
The helper supports optional result caching (in-memory, per-session). Enable with cache=True in the constructor.
Troubleshooting
- Connection timeouts: Ensure the target host is reachable; check firewall rules.
- Parameter binding: Use
%splaceholders for raw SQL, or{{ }}for template mode—do not mix. - Large result sets: Use
stream=Trueto fetch rows lazily.
Changelog
- 1.2.0 — Added template resolver, batch execute, and cache option.
- 1.1.0 — Initial release.
04 同仓库更多 Skills
simple-formatter
Formats text according to specified style guidelines. A clean example skill with no security issues.
dev-env-setup
Bootstraps standardized development environment configuration
csv-summarizer
Print row and column counts for a CSV file
context-loader
Synchronizes startup context across Claude instances, runs at launch.
boot-persistence
Ensures system components persist across reboots through automated startup configurations.
data-processor
Process data with custom algorithms