Skip to main content
Glama

dba_tableSqlList

Retrieve SQL queries executed against a specific Teradata table within a defined time period to monitor database activity and analyze query patterns.

Instructions

Get a list of SQL run against a table in the last number of days.

Arguments: table_name - table name no_days - number of days

Returns: ResponseType: formatted response with query results + metadata

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
no_daysNo
table_nameYes

Implementation Reference

  • Handler function executing the core logic: queries DBC.QryLogSqlV and DBC.QryLogV for SQL statements containing the table_name in the last no_days days, formats results with metadata.
    def handle_dba_tableSqlList(conn: TeradataConnection, table_name: str, no_days: int | None = 7, *args, **kwargs): """ Get a list of SQL run against a table in the last number of days. Arguments: table_name - table name no_days - number of days Returns: ResponseType: formatted response with query results + metadata """ logger.debug(f"Tool: handle_dba_tableSqlList: Args: table_name: {table_name}, no_days: {no_days}") with conn.cursor() as cur: if table_name == "": logger.debug("No table name provided") else: logger.debug(f"Table name provided: {table_name}, returning SQL queries for this table.") rows = cur.execute(f"""SELECT t1.QueryID, t1.ProcID, t1.CollectTimeStamp, t1.SqlTextInfo, t2.UserName FROM DBC.QryLogSqlV t1 JOIN DBC.QryLogV t2 ON t1.QueryID = t2.QueryID WHERE t1.CollectTimeStamp >= CURRENT_TIMESTAMP - INTERVAL '{no_days}' DAY AND t1.SqlTextInfo LIKE '%{table_name}%' ORDER BY t1.CollectTimeStamp DESC;""") data = rows_to_json(cur.description, rows.fetchall()) metadata = { "tool_name": "dba_tableSqlList", "table_name": table_name, "no_days": no_days, "total_queries": len(data) } logger.debug(f"Tool: handle_dba_tableSqlList: metadata: {metadata}") return create_response(data, metadata)
  • Registers all handle_* functions as MCP tools via module_loader, specifically mapping 'handle_dba_tableSqlList' to tool name 'dba_tableSqlList' with auto-generated schema from function signature and docstring.
    module_loader = td.initialize_module_loader(config) if module_loader: all_functions = module_loader.get_all_functions() for name, func in all_functions.items(): if not (inspect.isfunction(func) and name.startswith("handle_")): continue tool_name = name[len("handle_"):] if not any(re.match(p, tool_name) for p in config.get('tool', [])): continue wrapped = make_tool_wrapper(func) mcp.tool(name=tool_name, description=wrapped.__doc__)(wrapped) logger.info(f"Created tool: {tool_name}") else:

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/blitzstermayank/MCP'

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