当前位置: 首页 > Skill >

Test Mysql Db

Test Mysql Db

1.0.0 2026.11.07 浏览:269
获取Skill文件查看使用说明
作者:林景许可证:
本文目录展开

Test MySQL DB

Use this skill to query and validate test-environment MySQL data while keeping credentials and write operations controlled.

Safety Rules

  • Treat all database credentials as secrets. Do not write hostnames, usernames, passwords, or DSNs into skill files, repo files, chat, logs, or generated artifacts unless the user explicitly asks for a redacted template.
  • Prefer read-only operations. For INSERT, UPDATE, DELETE, DDL, or stored procedure calls, get explicit user confirmation in the current conversation and state the target environment, database, table, predicate, expected row count, and rollback plan first.
  • Never run destructive broad statements such as unconstrained DELETE, unconstrained UPDATE, DROP, TRUNCATE, or schema changes unless the user explicitly asks and the target is confirmed as a disposable test database.
  • Use narrow predicates, LIMIT, and transactions where possible. For write validation, capture before/after query results.
  • Redact passwords, tokens, personal data, payment data, and secrets in final responses.

Connection Discovery

Find connection details from the safest available source:

  1. Existing project configuration for the test/dev profile, such as Spring application-dev.yml, application-test.yml, Nacos/Apollo/local config, Docker Compose, .env, CI variables, or documented runbooks.
  2. Environment variables already present in the shell, preferably:
    • TEST_MYSQL_HOST
    • TEST_MYSQL_PORT
    • TEST_MYSQL_USER
    • TEST_MYSQL_PASSWORD
    • TEST_MYSQL_DATABASE
  3. A user-provided one-time value in chat, redacted after use in summaries.

If multiple test databases are plausible, identify the service/module and ask only for the missing disambiguation.

Query Workflow

  1. Clarify the business key to query: order number, request id, trace id, user id, batch id, table name, or service/module.
  2. Inspect relevant code/config first when the table or database is unclear. Use rg to find mapper XML, repository methods, entity classes, migration files, and datasource config.
  3. Build the smallest SQL that answers the question. Prefer selecting explicit columns over SELECT * when the table is wide or sensitive.
  4. Run read-only SQL with scripts/mysql_query.py when Python MySQL drivers are available, or use the local mysql client if the environment already provides it.
  5. Summarize findings with redacted values and include the exact safe SQL shape when useful.

Write Or Validation Workflow

For new code that writes database data:

  1. Read the implementation path to determine affected database, table, and expected fields.
  2. Query the before state if possible.
  3. Trigger or wait for the relevant test action if the user asks for end-to-end validation.
  4. Query the after state with a narrow predicate.
  5. Compare actual rows with the expected code behavior, including default values, enum values, timestamps, and nullable fields.

For explicit test-data fixes:

  1. Draft the SQL and a rollback SQL first.
  2. Ask for explicit confirmation unless the user has already given a direct command for that exact SQL and target.
  3. Run inside a transaction when supported by the operation.
  4. Verify affected row count and final state.

Helper Script

Use scripts/mysql_query.py for repeatable CLI execution:

python scripts/mysql_query.py --sql "select 1"
python scripts/mysql_query.py --database order_deve --sql-file work/query.sql --format table
python scripts/mysql_query.py --allow-write --sql-file work/fix.sql

The script reads connection values from TEST_MYSQL_* environment variables by default. It rejects non-read SQL unless --allow-write is passed.

Output Style

  • For troubleshooting, lead with the conclusion and the rows or fields that prove it.
  • For validation, report expected vs actual database state.
  • For failed connections, report which non-secret part is missing or failed, such as host, port, network reachability, driver availability, or database name.

推荐文章

更多
PHP时间戳与日期字符串相互转换方法详解

本文介绍PHP中时间数值(Unix时间戳)与日期字符串之间的相互转换方法。通过strtotime和date函数,实现将当前时间、指定日期转换为时间戳,以及将时间戳格式化为可读的日期时间字符串,并提供相关在线计算工具推荐。

2025.11.30 1,031
PHP日期转时间戳时区偏差怎么解决

在 PHP 中将日期字符串转换为时间戳时,若未显式指定时区,默认使用脚本配置的 date.timezone 或系统时区。当服务器时区与业务逻辑预期(如 UTC )不一致时,会产生偏差。解决核心是确保输入字符串携带明确时区信息,或在转换前统一设置时区上下文。

2026.10.24 1,029
PHP跨域配置:怎么安全地允许指定域名而非使用通配符

在 PHP 中安全地允许指定域名跨域,核心是解析请求头中的 Origin ,验证其是否在白名单内,然后动态设置 Access-Control-Allow-Origin 响应头。不要使用通配符 * ,也不要硬编码单一域名。

2025.03.29 1,017
JavaScript中利用replace结合正则实现replaceAll效果

JavaScript原生仅支持replace()进行单次或全局替换,缺乏类似Java的replaceAll()便捷方法。本文总结四种在JS中实现全量替换的方案:使用带g标志的正则、带gm标志的正则、扩展String原型以及split后join。通过对比代码示例,展示各方法的实现细节与适用场景,帮助开发者根据需求选择最优解。

2025.04.29 1,014
OpenAI的Jalapeno芯片未落地,教你分辨300兆瓦算力消息

OpenAI计划在SB Energy租赁的数据中心部署约300兆瓦自研Jalapeno推理芯片,但目前双方仍处于洽谈阶段,交易细节与上线时间表均未公布。本文带你按报道原文核实项目所处阶段,厘清芯片发布、电力功率与实际推理算力的边界,并将融资意向与签约、开工、投运节点分开追踪,避免误将规划容量计入现有算力。

2026.12.02 1,011
PHP实现基础文件上传:HTML表单与$_FILES处理流程

在 HTML 表单中设置 enctype="multipart/form-data" ,并在 PHP 后端通过 $_FILES 数组接收文件,调用 move_uploaded_file() 将临时文件移动到目标目录即可完成上传。

2026.09.07 1,011
Skill 文件

相关 Skill

更多
Volcengine RDS Mysql Volcengine RDS Mysql 使用火山引擎 RDS MySQL MCP Server,帮助用户完成 RDS MySQL 相关的实例管理、数据库操作、账号管理和运维任务,可直接调用 uv run ./scripts/call_rds_mysql.py 脚本获取实时结果。
Aliyun Adb Mysql Aliyun Adb Mysql 用于通过 OpenAPI/SDK 管理阿里云 AnalyticDB for MySQL (ADB),包括资源生命周期及配置操作。
MYSQL QUERY MYSQL QUERY 自动管理SSH隧道,查询项目数据库。适用于在已配置的数据库上执行SQL查询,尤其是需要通过SSH访问的数据库。
MySQL to PostgreSQL Migration MySQL to PostgreSQL Migration 在将项目数据库层从MySQL迁移到PostgreSQL时使用此技能。覆盖SQL方言转换(MyBatis XML/原始SQL)和ORM配置等...
在使用 Skeema 进行危险的数据库部署之前,将 MySQL 架构变更作为文件系统管理的 SQL 进行差异对比和审查 在使用 Skeema 进行危险的数据库部署之前,将 MySQL 架构变更作为文件系统管理的 SQL 进行差异对比和审查 将实时MySQL模式拉取到文件中,检查差异,并使用可重复的工作流程推送已审核的更改。