Skip to main content
Glama
aliyun

Hologres MCP Server

Official
by aliyun

execute_hg_dml_sql

Execute INSERT, UPDATE, and DELETE SQL queries to manage data within a Hologres database, enabling efficient data manipulation and modification.

Instructions

Execute (INSERT, UPDATE, DELETE) SQL to insert, update, and delete data in Hologres databse.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
queryYesThe DML SQL query to execute in Hologres database

Implementation Reference

  • Specific dispatch and validation handler for the 'execute_hg_dml_sql' tool within the @app.call_tool() function. Extracts the SQL query and ensures it is a valid DML statement (INSERT, UPDATE, or DELETE). Then passes to handle_call_tool for execution.
    elif name == "execute_hg_dml_sql": query = arguments.get("query") if not query: raise ValueError("Query is required") if not any(query.strip().upper().startswith(keyword) for keyword in ["INSERT", "UPDATE", "DELETE"]): raise ValueError("Query must be a DML statement (INSERT, UPDATE, DELETE)") elif name == "execute_hg_ddl_sql":
  • Core execution helper function called by the tool handler. Establishes database connection, optionally sets serverless mode, executes the SQL query, and formats results or reports success/rowcount/error.
    def handle_call_tool(tool_name, query, serverless = False): """Handle callTool method.""" config = get_db_config() try: with connect_with_retry() as conn: with conn.cursor() as cursor: # 特殊处理 serverless computing 查询 if serverless: cursor.execute("set hg_computing_resource='serverless'") # Execute the query cursor.execute(query) # 特殊处理 ANALYZE 命令 if tool_name == "gather_hg_table_statistics": return f"Successfully {query}" # 处理其他有返回结果的查询 if cursor.description: # SELECT query columns = [desc[0] for desc in cursor.description] rows = cursor.fetchall() result = [",".join(map(str, row)) for row in rows] return "\n".join([",".join(columns)] + result) elif tool_name == "execute_dml_sql": # Non-SELECT query row_count = cursor.rowcount return f"Query executed successfully. {row_count} rows affected." else: return "Query executed successfully" except Exception as e: return f"Error executing query: {str(e)}"
  • Registration of the 'execute_hg_dml_sql' tool in the list_tools() function, including name, description, and input schema definition.
    Tool( name="execute_hg_dml_sql", description="Execute (INSERT, UPDATE, DELETE) SQL to insert, update, and delete data in Hologres databse.", inputSchema={ "type": "object", "properties": { "query": { "type": "string", "description": "The DML SQL query to execute in Hologres database" } }, "required": ["query"] } ),
  • Input schema definition for the 'execute_hg_dml_sql' tool, specifying a required 'query' string parameter.
    inputSchema={ "type": "object", "properties": { "query": { "type": "string", "description": "The DML SQL query to execute in Hologres database" } }, "required": ["query"] }

Latest Blog Posts

MCP directory API

We provide all the information about MCP servers via our MCP API.

curl -X GET 'https://glama.ai/api/mcp/v1/servers/aliyun/alibabacloud-hologres-mcp-server'

If you have feedback or need assistance with the MCP directory API, please join our Discord server