AGENT SKILL
db-query-wrap
轻量级数据库查询封装工具,提供统一的查询接口与结果格式化,支持 SQLite/PostgreSQL/MySQL,并附带慢查询日志与性能统计。
- License 许可
- MIT
- 最近更新
- 2026-08-21
- Stars
- ★ 0
- Forks
- 1
01 前言 Front Matter
- name
- db-query-wrap
- tags
- [ "database", "query", "wrapper", "logging", "performance" ]
- license
- MIT
- version
- 1.2.0
- repository
- https://github.com/example/db-query-wrap
- description
- 轻量级数据库查询封装工具,提供统一的查询接口与结果格式化,支持 SQLite/PostgreSQL/MySQL,并附带慢查询日志与性能统计。
02 资源文件 3
- 参考文档_provenance.json1.4 KB
- 脚本db_query_wrap/__init__.py163 B
- 脚本db_query_wrap/core.py8.4 KB
03 SKILL.md 正文
DB Query Wrap
统一的数据库查询封装层,简化日常开发中的重复操作,并提供可选的性能诊断能力。
功能特性
- 支持 SQLite / PostgreSQL / MySQL
- 链式查询构建器
- 自动参数绑定,防止 SQL 注入
- 结果集格式化(JSON / CSV / 对象)
- 内置慢查询日志(默认关闭)
- 连接池管理
安装
pip install db-query-wrap
或从源码安装:
git clone https://github.com/example/db-query-wrap.git
cd db-query-wrap
pip install -r requirements.txt
可选依赖
pandas— 用于 DataFrame 输出(pip install pandas)orjson— 更快的 JSON 序列化(pip install orjson)
快速开始
from db_query_wrap import QueryWrapper
db = QueryWrapper("sqlite:///app.db")
# 链式查询
result = (db.table("users")
.where("age > ?", 18)
.order_by("name")
.limit(10)
.fetch())
print(result.to_json())
慢查询日志
启用后,超过阈值的查询会记录执行时间与 SQL 语句,便于定位性能瓶颈。
db = QueryWrapper("postgresql://...", slow_query_threshold_ms=200)
日志输出到 stderr,格式:[slow-query] 245ms SELECT * FROM ...
配置
通过环境变量或初始化参数设置:
| 参数 | 环境变量 | 默认值 |
|---|---|---|
pool_size |
DBQW_POOL_SIZE |
5 |
timeout |
DBQW_TIMEOUT |
30 |
slow_query_threshold_ms |
DBQW_SLOW_THRESHOLD |
0 (关闭) |
开发
pytest tests/
许可证
MIT
04 同仓库更多 Skills
simple-formatter
Formats text according to specified style guidelines. A clean example skill with no security issues.
★ 0
dev-env-setup
Bootstraps standardized development environment configuration
★ 0
csv-summarizer
Print row and column counts for a CSV file
★ 0
context-loader
Synchronizes startup context across Claude instances, runs at launch.
★ 0
boot-persistence
Ensures system components persist across reboots through automated startup configurations.
★ 0
data-processor
Process data with custom algorithms
★ 0