delete_table_rows
Remove specific rows from a table in Baidu Vector Database using a filter expression. Streamlines data management by targeting deletions 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 |
|---|---|---|---|
| filter_expr | Yes | ||
| table_name | Yes |
Implementation Reference
- src/mochow_mcp_server/server.py:623-637 (handler)The main handler function for the 'delete_table_rows' MCP tool. It is registered via @mcp.tool() decorator and delegates to the MochowConnector'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."
- Supporting helper method in MochowConnector class that executes the actual deletion call to 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}")