@oh-my-tool/mysql
v0.3.4
Published
MySQL extension for Oh My Tool (read-only query / schema / explain)
Maintainers
Readme
@oh-my-tool/mysql
独立 MySQL 能力扩展仓库(Oh My Tool)。
- 只读:
mysql.instances/mysql.ping/mysql.query/mysql.schema/mysql.explain - 契约:
omt.manifest.json声明sdkVersion,Core 安装/发现时做 SDK 版本兼容校验。 - 依赖:
@oh-my-tool/sdk;发布包会将运行时 bundle 自包含,无需在 Core 的扩展目录中额外安装 SDK。 - 测试:
npm test(handler 逻辑,注入 mock client)。
配置
配置文件位于 %USERPROFILE%\\.oh-my-tool\\config.toml(Linux/macOS 为 ~/.oh-my-tool/config.toml)。
[extensions.mysql.connections.local]
environment = "local"
[extensions.mysql.connections.local.settings]
host = "127.0.0.1"
port = 3306
database = "ohmytool_test"
username = "root"
tls = true
[extensions.mysql.connections.local.secrets]
password = "mysql:local"secrets.password 只保存密钥引用,不保存密码。设置密码:
"your-password" | ohmytool secret set mysql:localmysql.query、mysql.schema 和 mysql.explain 都只接受已配置的 connection 名称。
mysql.instances 不需要连接名,会列出当前配置的实例(不连接 MySQL,也不显示 secret 名称)。
mysql.ping 检查连接和认证;query、schema、explain 默认最多返回 100 行,
可传 maxRows(上限 1000)和 timeoutMs(上限 30000)。超出限制时返回
truncated: true。
ohmytool run mysql.instances
ohmytool run mysql.instances --json
ohmytool run mysql.ping connection=iot-test
ohmytool run mysql.query connection=iot-test sql="SELECT id, name, age FROM users"
ohmytool run mysql.query connection=iot-test sql="SELECT id, name, age FROM users" --jsonrun 默认以行数组输出查询结果:第一行是列名,后续行是数据;增加 --json 可输出机器可解析的 JSON,也支持 --format=text|json|table|csv。
本地联调
npm install
npm test安装进 Core
npm install @oh-my-tool/mysql
ohmytool extension install ./node_modules/@oh-my-tool/mysql发布
发布由 GitHub Actions 的 npm Trusted Publisher 完成。创建并推送与 package.json、omt.manifest.json 一致的版本 tag 即可:
npm run version:release -- 0.2.1
npm install
npm run check
git add -A && git commit -m "release: v0.2.1"
git push origin main
git tag -a v0.2.1 -m "release: v0.2.1"
git push origin v0.2.1