Source code for tibco.liveview.models.table_metadata

from typing import Optional, List


[docs]class TableMetadata: """LiveView Table metadata. A TableMetadata object should not be instantiated directly, but should be obtained through LiveViewClient#get_table_metadata(). Attributes: - name (str): The name of the table - schema (str): The schema of the table - keys (list): The key(s) of the table Parameters: - table_metadata: The swagger table_info returned by a get_table request. """ def __init__(self, tbl) -> None: self._info = tbl.to_dict() self.name = self._info.get('name') self.schema = self._info.get('schema') self.keys = self._info.get('indices')
[docs] def column_names(self) -> List[str]: """Get a list of all the column names of this table""" return list(self.schema.keys())
[docs] def to_dict(self) -> dict: """Returns the table as a dict, including all advanced fields. Returns: dict: this table's metadata """ return self._info
def __str__(self) -> str: return f'Name: {self.name},\nSchema: {self.schema},\nKeys: {self.keys}'
[docs] def get(self, field) -> Optional[str]: """Get the value of a field from this table's metadata """ return self._info.get(field)