DescribeTable オペレーションを呼び出すことで、テーブルのスキーマ情報、予約済み読み取りスループット、予約済み書き込みスループットなどの説明をクエリできます。
説明
DescribeTable オペレーションの詳細については、DescribeTable を参照してください。
前提条件
OTSClient インスタンスが初期化されていること。詳細については、OTSClient インスタンスの初期化 を参照してください。
データテーブルが作成されていること。詳細については、データテーブルの作成 を参照してください。
API オペレーション
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.")
詳細なサンプルコードについては、GitHub の DescribeTable を参照してください。