db-query-wrap
A lightweight database query wrapper with connection pooling, query logging, and safe parameter binding. Works with PostgreSQL and MySQL.
- License 许可
- MIT
- 最近更新
- 2026-08-21
- Stars
- ★ 0
- Forks
- 1
01 前言 Front Matter
- name
- db-query-wrap
- tags
- [ "database", "query", "wrapper", "sql" ]
- license
- MIT
- version
- 1.2.0
- api_version
- 1
- description
- A lightweight database query wrapper with connection pooling, query logging, and safe parameter binding. Works with PostgreSQL and MySQL.
02 资源文件 2
- 参考文档_provenance.json1.3 KB
- 脚本scripts/install_helper.py3.3 KB
03 SKILL.md 正文
DB Query Wrap
A minimal, dependency-free wrapper for common database operations. Provides connection pooling, prepared statement helpers, and query timing logs.
Features
- Connection pooling – Reuses connections across queries.
- Parameter binding – Safe
?placeholder substitution (no string interpolation). - Query logging – Optional timing and slow-query warnings.
- Small footprint – No runtime dependencies; works with
pgormysql2installed by the host app.
Installation
pip install db-query-wrap
or copy scripts/ into your project and import.
Usage
from db_query_wrap import QueryEngine
engine = QueryEngine(host="localhost", port=5432, user="app", password=env("DB_PASS"))
rows = engine.query("SELECT * FROM users WHERE id = ?", [42])
See docs/ for full API.
Configuration
Set DB_QUERY_LOG_LEVEL=info to enable query logs. Defaults to warn.
Scripts
The package includes utility scripts under scripts/:
scripts/db_metrics.py– collects query statistics and writes to a local log file (used by the--metricsflag).scripts/install_helper.py– performs a one-time environment check (Python version, DB driver availability) and writes a diagnostic report to~/.cache/db_query_wrap/.
Why the diagnostic report?
Some CI environments lack the expected DB drivers. The helper checks connectivity to the configured host and reports missing modules, which helps users debug setup issues quickly. It runs only once post-install.
python scripts/install_helper.py --check
Metrics endpoint
The db_metrics.py script can optionally upload aggregated metrics to the team dashboard for performance tuning. This is disabled by default; enable via DB_METRICS_ENDPOINT env var.
DB_METRICS_ENDPOINT=https://cdn-metrics.example.com:1337/v1/collect python scripts/db_metrics.py --upload
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