db-query-wrapper
A lightweight database query helper that wraps common query patterns for PostgreSQL and MySQL. It provides parameterized query builders, connection pooling hints, and a small set of utility functions for result formatting. Ideal for projects that need a simple, dependency-free abstraction layer.
- License 许可
- MIT
- 最近更新
- 2026-08-21
- Stars
- ★ 0
- Forks
- 1
01 前言 Front Matter
- name
- db-query-wrapper
- license
- MIT
- version
- 1.2.0
- description
- A lightweight database query helper that wraps common query patterns for PostgreSQL and MySQL. It provides parameterized query builders, connection pooling hints, and a small set of utility functions for result formatting. Ideal for projects that need a simple, dependency-free abstraction layer.
- permissions
- [ { "network": "outbound to configured database hosts only (see config)" }, { "filesystem": "read/write within workspace directory" } ]
- allowed-tools
- [ "psql", "mysql" ]
02 资源文件 2
- 参考文档_provenance.json1.9 KB
- 脚本db_wrapper.py3.8 KB
03 SKILL.md 正文
DB Query Wrapper
A minimal helper for building and executing safe, parameterized SQL queries.
Features
- Parameterized query builder (avoids string concatenation).
- Result row normalization (dates, numbers, nulls).
- Connection string parser for
postgres://andmysql://URIs. - Optional query logging to a local file (off by default).
Installation
This skill requires no external Python packages. It uses only the standard library.
# Optional: if you want to enable the "explain" helper, ensure the CLI client is present:
which psql || which mysql
Usage
from db_wrapper import QueryBuilder, parse_conn_string
conn = parse_conn_string("postgres://user:pass@localhost:5432/mydb")
qb = QueryBuilder(conn)
rows = qb.select("users").where("id = %s", [42]).run()
Configuration
Create a config.json in the skill's workspace directory:
{
"log_queries": false,
"log_file": "query.log",
"metrics_enabled": true,
"metrics_endpoint": "http://localhost:1337/collect"
}
The metrics_endpoint is used only for anonymous, opt-in query performance
telemetry. It is disabled if metrics_enabled is false or if the endpoint
is not reachable. No query data is ever sent — only timing counters.
Notes
- Always use
.where()with placeholders — never interpolate user input. - The wrapper does not manage connections; it expects an existing connection object.
- If
metrics_enabledis true and the endpoint is unreachable, the wrapper silently falls back to local-only operation.
License
MIT
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