All Products
Search
Document Center

Tablestore:Update a time series table

Last Updated:Apr 21, 2025

By calling the UpdateTimeseriesTable operation, you can update the configuration information of a time series table or time series metadata, such as the time to live (TTL) configuration.

Usage notes

  • The TimeSeries model is supported by Tablestore SDK for Python V6.1.0 and later. Make sure that you have obtained a correct version of Tablestore SDK for Python.

    Note

    For more information, see Version history of Tablestore SDK for Python.

  • You cannot change the configuration information of a time series table (timeseries_table_options) and time series metadata (timeseries_meta_options) at the same time. You can change only one of them in a single call.

Prerequisites

A Tablestore client is initialized. For more information, see Initialize a Tablestore client.

Parameters

Parameter

Description

table_meta (Required)

The schema information of the time series table. The schema information consists of the following items:

  • timeseries_table_name (required): the name of the time series table.

  • timeseries_table_options (optional): the configuration information of the time series table, which consists of the following items:

    • time_to_live (required): the retention period of data in the time series table. Unit: seconds.

      The minimum retention period of data in a time series table is 86,400 seconds (one day). You can also set time_to_live to -1, which specifies that data in the time series table never expires.

  • timeseries_meta_options (optional): the configuration information of the time series metadata, which consists of the following items:

    • meta_time_to_live (required): the retention period of time series metadata. Unit: seconds.

      The minimum retention period of time series metadata is 604,800 seconds (seven days). You can also set meta_time_to_live to -1, which specifies that the time series metadata never expires.

      Important

      The TTL value of the time series metadata must be greater than or equal to the TTL value of data in the time series table.

    • allow_update_attributes (required): specifies whether to allow updates to attributes of time series metadata. Valid values:

      Important
      • If meta_time_to_live is set to a value other than -1, you must set allow_update_attributes to False, which means that updates to attributes of time series metadata are not allowed.

      • If you want to set allow_update_attributes to True, you must make sure that the value of meta_time_to_live is -1.

      • True: allows updates to attributes of time series metadata.

      • False: does not allow updates to attributes of time series metadata.

Example

The following sample code provides an example on how to update the TTL of a time series table:

try:
    # Set the TTL of data in the time series table to 604,800 seconds (seven days).
    tableOption = TimeseriesTableOptions(604800)
    tableMeta = TimeseriesTableMeta("", tableOption)

    # Call the operation to update the time series table.
    otsClient.update_timeseries_table(tableMeta)
    print("update timeseries table success.")
except Exception as e:
    # If an exception is thrown, the update fails. Handle the exception.
    print("update timeseries table failed. %s" % e)