文档

查询表描述信息

更新时间:

使用DescribeTable接口可以查询指定表的结构、预留读/写吞吐量详情等信息。

说明

API说明请参见DescribeTable

前提条件

接口

def describe_table(self, table_name):

返回值为表的描述信息。返回结果中describe_table_response表示表的描述信息,是ots2.metadata.DescribeTableResponse类的实例。

参数

参数

说明

table_name

表名。

示例

以下示例用于获取表的描述信息。

try:
    describe_response = ots_client.describe_table('SampleTable')
    # 如果没有抛出异常,则说明执行成功,打印如下表信息。
    print("describe table succeeded.")
    print('TableName: %s' % describe_response.table_meta.table_name)
    print('PrimaryKey: %s' % describe_response.table_meta.schema_of_primary_key)
    print('Reserved read throughput: %s' % describe_response.reserved_throughput_details.capacity_unit.read)
    print('Reserved write throughput: %s' % describe_response.reserved_throughput_details.capacity_unit.write)
    print('Last increase throughput time: %s' % describe_response.reserved_throughput_details.last_increase_time)
    print('Last decrease throughput time: %s' % describe_response.reserved_throughput_details.last_decrease_time)
    print('table options\'s time to live: %s' % describe_response.table_options.time_to_live)
    print('table options\'s max version: %s' % describe_response.table_options.max_version)
    print('table options\'s max_time_deviation: %s' % describe_response.table_options.max_time_deviation)
except Exception:
    # 如果抛出异常,则说明执行失败,处理异常。
    print("describe table failed.")
            

详细代码请参见DescribeTable@GitHub

  • 本页导读 (1)
文档反馈