SuperAPI AI 工具集

sqlite-crud

数据与分析

查看项目

更新于 10-15 21:41

技能介绍

用途:通过保存的本地 SQLite 文件配置(profile)安全地检查、查询和修改本地 SQLite 数据库文件。该技能使用 Bash 脚本和 sqlite3 CLI,不依赖 Python 或 jq,仅支持本地 SQLite 文件路径,不支持 SSH、远程主机或 MySQL、PostgreSQL、Redis、MongoDB 等其他数据库。

主要能力:保存可复用的本地数据库文件配置;查看表和列;执行 select、insert、update、delete 及原始 SQL。输出为 JSON,打印到 stdout,并默认保存到 ./out/sqlite-crud-<UTC 时间戳>-<pid>.json。

使用方式:配置 profile 使用 configure,例如 bash <skill-path>/scripts/sqlite_crud.sh configure --profile local --path /Users/me/app/data.sqlite --default,可加 --test-connection 验证文件可打开。未配置 profile 时需用 --path 提供明确本地路径,脚本会将其保存为默认 profile。查看表用 schema --profile local,查看某表列用 schema --profile local --table users。查询用 select,支持 --where、--param、--columns、--order-by、--desc、--limit。写入操作先 dry-run,确认后再加 --execute。update 和 delete 需要 --where,除非用户明确确认全表操作并传 --allow-full-table。原始写 SQL 需同时传 --execute 和 --allow-raw-write。

限制与安全规则:不要在本仓库保存数据库文件或副本,除非用户明确要求;profile 存于 ~/.config/sqlite-crud/profiles/,默认 profile 名存于 ~/.config/sqlite-crud/default_profile,每个 profile 为 0600 配置文件。不要扫描文件系统查找 SQLite 文件,应询问用户确切路径。默认不加 --readonly,仅在用户明确要求只读 profile 时使用;readonly profile 不得用于写入。不要臆造表名或列名,不确定时先运行 schema。优先使用结构化命令而非 raw-sql。SQLite 可能因其他进程占用而锁定文件,写入失败时未经用户批准不要重试大范围写入。