delete_table_rows
Remove specific rows from a Baidu Vector Database table using filter expressions to delete targeted data based on defined criteria.
Instructions
Delete rows with a filter expression in the Mochow instance.
Args:
table_name (str): Name of the table.
filter_expr (str): Filter expression to select data to delete.
Returns:
str: A message indicating the success of data deletion.
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| table_name | Yes | ||
| filter_expr | Yes |
Implementation Reference
- src/mochow_mcp_server/server.py:623-637 (handler)MCP tool handler for 'delete_table_rows' that deletes rows from a specified table using a filter expression by calling the connector's delete_rows method.@mcp.tool() async def delete_table_rows(table_name: str, filter_expr: str, ctx: Context = None) -> str: """ Delete rows with a filter expression in the Mochow instance. Args: table_name (str): Name of the table. filter_expr (str): Filter expression to select data to delete. Returns: str: A message indicating the success of data deletion. """ connector = ctx.request_context.lifespan_context.connector await connector.delete_rows(table_name, filter_expr) return f"Delete rows with filter expression '{filter_expr}' successfully."
- Helper method in MochowConnector class that executes the actual row deletion using the Mochow database API.async def delete_rows(self, table_name: str, filter_expr: str) -> bool: """ Delete rows in a given table using a filter expression. Args: table_name (str): Name of the table. filter_expr (str): Filter expression to select data to delete. Returns: bool: True if the rows is deleted successfully, False otherwise. """ if self.database is None: raise ValueError("Switch to the database before delete rows with filter expression.") try: self.database.table(table_name).delete(filter=filter_expr) return True except Exception as e: raise ValueError(f"Failed to delete data with filter expression: {filter_expr}")
- src/mochow_mcp_server/server.py:623-623 (registration)Registration of the 'delete_table_rows' tool using the @mcp.tool() decorator.@mcp.tool()