Use Tablestore SDK for Python to update the TTL, version, update mode, and reserved throughput configurations of a table.
Prerequisites
Install the Tablestore SDK for Python and initialize a client.
Function description
Call the update_table method to update table configurations. You must specify at least one of table_options and reserved_throughput.
def update_table(
self,
table_name,
table_options=None,
reserved_throughput=None,
)
The following example changes the TTL of example_table to seven days and disables updates by the update_row method.
table_options = TableOptions(
time_to_live=604800,
max_version=1,
max_time_deviation=86400,
allow_update=False,
)
client.update_table(
"example_table",
table_options=table_options,
)
Parameters
The update_table method contains the following parameters.
|
Name |
Type |
Description |
|
table_name (required) |
|
The name of the table. |
|
table_options (optional) |
|
The table configurations to update. You must specify at least one of this parameter and |
|
reserved_throughput (optional) |
|
The reserved throughput to update. You must specify at least one of this parameter and |
Table configurations
The table_options parameter is of the TableOptions type and contains the following parameters.
|
Name |
Type |
Description |
|
time_to_live (optional) |
|
The TTL of data in seconds. A value of |
|
max_version (optional) |
|
The maximum number of versions to retain for each attribute column. To use a search index or secondary index, set this parameter to |
|
max_time_deviation (optional) |
|
The maximum version deviation in seconds. The difference between the timestamp of the data to write and the current system time must be within the maximum version deviation. The valid version range is |
|
allow_update (optional) |
|
Specifies whether data can be updated by calling |
Reserved throughput
The reserved_throughput parameter is of the ReservedThroughput type and contains the following parameter.
|
Name |
Type |
Description |
|
capacity_unit (required) |
|
The reserved throughput in CUs. Only high-performance instances in CU mode support nonzero values. |
Response
UpdateTableResponse contains the following business information.
|
Field |
Type |
Description |
|
table_options |
|
The updated table configurations. |
|
reserved_throughput_details |
|
The current reserved throughput and the times of the latest increase and decrease. |
Examples
Update reserved throughput
The following example sets the reserved throughput of example_table to 0 CUs.
reserved_throughput = ReservedThroughput(
CapacityUnit(read=0, write=0)
)
client.update_table(
"example_table",
reserved_throughput=reserved_throughput,
)