mysql_delete
Delete data from MySQL database tables by specifying table name and conditions. Use this tool to remove specific records while maintaining database integrity.
Instructions
删除表数据
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| tableName | Yes | 表名称 | |
| where | Yes | 删除条件 |
Implementation Reference
- src/server.ts:454-469 (handler)The handler function for the 'mysql_delete' tool. It constructs a parameterized DELETE SQL statement using the provided tableName and where conditions, executes it via the DatabaseManager, and returns a response indicating the number of affected rows.private async handleDelete(args: { tableName: string; where: any }): Promise<any> { const whereClause = Object.keys(args.where).map(key => `\`${key}\` = ?`).join(' AND '); const sql = `DELETE FROM \`${args.tableName}\` WHERE ${whereClause}`; const params = Object.values(args.where); const result = await this.dbManager.query(sql, params); return { content: [ { type: 'text', text: `成功删除 ${result.affectedRows} 行数据`, }, ], }; }
- src/server.ts:184-195 (schema)The input schema definition for the 'mysql_delete' tool, specifying required parameters: tableName (string) and where (object).{ name: 'mysql_delete', description: '删除表数据', inputSchema: { type: 'object', properties: { tableName: { type: 'string', description: '表名称' }, where: { type: 'object', description: '删除条件' }, }, required: ['tableName', 'where'], }, },
- src/server.ts:257-258 (registration)The switch case registration that maps the 'mysql_delete' tool call to the handleDelete handler function.case 'mysql_delete': return await this.handleDelete(args as any);