base_tableDDL
Generate and retrieve the DDL definition of a specified table in Teradata databases. Provides fully rendered SQL with metadata for database analysis and management.
Instructions
Displays the DDL definition of a table via SQLAlchemy, bind parameters if provided (prepared SQL), and return the fully rendered SQL (with literals) in metadata.
Arguments: database_name - Database name table_name - table name
Returns: ResponseType: formatted response with query results + metadata
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| database_name | Yes | ||
| table_name | Yes |
Implementation Reference
- The core handler function for the 'base_tableDDL' tool. It constructs the fully qualified table name if database_name is provided, executes 'SHOW TABLE' SQL command using the Teradata connection, fetches the results, formats them into JSON, and returns a standardized response with metadata including the tool name, database, table, and row count.def handle_base_tableDDL(conn: TeradataConnection, database_name: str | None, table_name: str, *args, **kwargs): """ Displays the DDL definition of a table via SQLAlchemy, bind parameters if provided (prepared SQL), and return the fully rendered SQL (with literals) in metadata. Arguments: database_name - Database name table_name - table name Returns: ResponseType: formatted response with query results + metadata """ logger.debug(f"Tool: handle_base_tableDDL: Args: database_name: {database_name}, table_name: {table_name}") if database_name is not None: table_name = f"{database_name}.{table_name}" with conn.cursor() as cur: rows = cur.execute(f"show table {table_name}") data = rows_to_json(cur.description, rows.fetchall()) metadata = { "tool_name": "base_tableDDL", "database": database_name, "table": table_name, "rows": len(data) } logger.debug(f"Tool: handle_base_tableDDL: metadata: {metadata}") return create_response(data, metadata)