switch_db
Change the active database in TDengine to execute queries on different datasets. Specify the target database name to switch context for subsequent operations.
Instructions
Switch to the specified database.
Args:
db_name (str): The name of the database to switch to.
Returns:
TaosSqlResponse: The result of the `USE` command.
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| db_name | Yes | The name of the database to switch to |
Implementation Reference
- The handler function `switch_db` executes the `USE {db_name};` SQL command via the TDengine client.
@mcp.tool(name="switch_db") def switch_db( ctx: Context, db_name: str = Field( description="The name of the database to switch to" ), ) -> TaosSqlResponse: """Switch to the specified database. Args: db_name (str): The name of the database to switch to. Returns: TaosSqlResponse: The result of the `USE` command. """ taos = ctx.request_context.lifespan_context.client result = taos.execute_sql(f"USE {db_name};") return result