base_tableDDL
Retrieve the complete DDL definition of a Teradata table to understand its structure and constraints. Provides fully rendered SQL with literals for analysis or documentation.
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 takes a Teradata connection, optional database name, and table name, constructs the full table identifier, executes 'SHOW TABLE' SQL command, fetches results, builds metadata including tool_name 'base_tableDDL', and returns a formatted response.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)