mysql_delete
Delete specific data from MySQL tables by defining the table name and conditions using the 'mysql_delete' tool. Simplify database management with targeted data removal.
Instructions
删除表数据
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| tableName | Yes | 表名称 | |
| where | Yes | 删除条件 |
Implementation Reference
- src/server.ts:454-468 (handler)The handler function for 'mysql_delete' tool. It constructs a parameterized DELETE SQL query using the provided tableName and where conditions object, executes it via dbManager.query, and returns a response with 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:185-195 (schema)The input schema definition for the 'mysql_delete' tool, specifying tableName and where object as required parameters.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 dispatches calls to 'mysql_delete' to the handleDelete method.case 'mysql_delete': return await this.handleDelete(args as any);
- src/server.ts:185-195 (registration)The tool registration in the ListTools response, including name, description, and schema.name: 'mysql_delete', description: '删除表数据', inputSchema: { type: 'object', properties: { tableName: { type: 'string', description: '表名称' }, where: { type: 'object', description: '删除条件' }, }, required: ['tableName', 'where'], }, },