75 lines
2.9 KiB
Markdown
75 lines
2.9 KiB
Markdown
---
|
|
name: bms-mysql-test
|
|
description: Connect to BMS test MySQL database. Use when the user asks to query BMS database, execute SQL against BMS, check BMS data, or says "查询BMS数据库", "执行SQL", "连接BMS MySQL", "BMS数据库". This skill handles safe SQL execution — SELECT runs directly, but INSERT/UPDATE/DELETE/DDL require Windows popup confirmation before executing.
|
|
---
|
|
|
|
# BMS MySQL 数据库连接 Skill
|
|
|
|
Connect to the BMS test environment MySQL database and execute SQL queries safely.
|
|
|
|
## Available Databases
|
|
|
|
| Database | Description |
|
|
| ----------------------- | -------------------- |
|
|
| `bms_base_center` | 基础数据中心 |
|
|
| `bms_buyinvoice_center` | 采购发票中心 |
|
|
| `bms_ext_center` | 外部扩展中心 |
|
|
| `bms_invoice_center` | 发票中心 |
|
|
| `bms_order_center` | 订单中心 |
|
|
| `bms_payable_center` | 应付中心 |
|
|
| `bms_task_center` | 任务中心 |
|
|
| `cache_db` | 缓存数据库 |
|
|
| `leshop_v3` | 乐商 V3 |
|
|
| `lts` | LTS |
|
|
| `manager_db` | 管理数据库 |
|
|
| `mq_db` | 消息队列数据库 |
|
|
| `sap_push_data` | SAP 推送数据 |
|
|
| `sf_db` | SF 数据库 |
|
|
| `mysql` | 系统数据库 |
|
|
| `information_schema` | 系统信息库 |
|
|
|
|
## How to Use
|
|
|
|
Run the helper script with a SQL query:
|
|
|
|
```bash
|
|
python scripts/bms-mysql.py --query "SELECT * FROM your_table LIMIT 10"
|
|
```
|
|
|
|
## Safety Rules
|
|
|
|
### Read-only queries — execute directly
|
|
- `SELECT`, `SHOW`, `DESC`, `DESCRIBE`, `EXPLAIN` — run without confirmation
|
|
- Results are printed in a formatted table
|
|
|
|
### Write / DDL operations — require confirmation
|
|
- `INSERT`, `UPDATE`, `DELETE`, `REPLACE`
|
|
- `CREATE`, `ALTER`, `DROP`, `TRUNCATE`, `RENAME`
|
|
- `GRANT`, `REVOKE`
|
|
- A Windows popup dialog displays the full SQL and asks for Yes/No confirmation
|
|
- Only executes if user clicks **是 (Yes)**
|
|
|
|
## Script Location
|
|
|
|
- `scripts/bms-mysql.py` — the execution script (uses PyMySQL)
|
|
|
|
## Examples
|
|
|
|
```bash
|
|
# Query user table (no confirmation needed)
|
|
python scripts/bms-mysql.py --query "SELECT id, name FROM users WHERE status = 1 LIMIT 20"
|
|
|
|
# Show tables (no confirmation needed)
|
|
python scripts/bms-mysql.py --query "SHOW TABLES"
|
|
|
|
# Delete a record (requires confirmation popup)
|
|
python scripts/bms-mysql.py --query "DELETE FROM logs WHERE created_at < '2025-01-01'"
|
|
|
|
# Alter table (requires confirmation popup)
|
|
python scripts/bms-mysql.py --query "ALTER TABLE users ADD COLUMN phone VARCHAR(20)"
|
|
```
|
|
|
|
## Output Format
|
|
|
|
Results are printed as a formatted table with column headers and aligned values. Empty results show "0 rows returned." Write operations show the number of affected rows.
|