The OTSClient is the client for Table Store, providing a series of methods for manipulating tables and reading/writing data from/to a single row or multiple rows.
An endpoint is the domain of Alibaba Cloud Table Store in a region. It supports the following format.
|Region address||The region of the current Table Store instance, for example,
To query the endpoint where your Table Store instance is located, follow these steps:
Log on to the Table Store console.
Go to the Instance Details page and locate the Instance Access URL, which is the endpoint of the instance.
To access Alibaba Cloud Table Store, you need a valid AccessKey (including an AccessKeyId and AccessKeySecret) for signature authentication. To obtain the AccessKey, follow these steps:
Register an Alibaba Cloud account.
Log on to the AccessKey console to create an AccessKeyId and AccessKeySecret.
After you obtain the AccessKeyID and AccessKeySecret, use the endpoint to initialize an OTSClient instance as follows.
Initialize the ``OTSClient`` instance.
``end_point`` is the Table Store service address (for example, 'https://instance.cn-hangzhou.ots.aliyun.com:80'), which must be prefixed with 'https://'.
``access_key_id`` is the accessid used to access Table Store.
``access_key_secret`` is the accesskey used to access Table Store.
``instance_name`` is the name of the instance to access. You can create an instance on the Alibaba Cloud Table Store console.
``sts_token`` is the STS token used to access Table Store. You can get this from Alibaba Cloud STS service. When the STS token is expired, you must reacquire it.
``encoding`` is the encoding type of the request parameter string. The default value is utf8.
``socket_timeout`` is the time-out of each connection socket in the connection pool. It can be an integer or float number in the unit of seconds. The default value is 50.
``max_connection`` is the maximum number of connection pool connections. The default value is 50.
``logger_name`` is used to print the DEBUG in the request or print the ERROR log when an error occurs.
``retry_policy`` defines the retry policy. By default, the retry policy is DefaultRetryPolicy. You can inherit a RetryPolicy class to implement your own retry policy. For more information, see the DefaultRetryPolicy code.
def __init__(self, endpoint, access_key_id, access_key_secret, instance_name, **kwargs):
######### Set the log file name and retry policy #########
# The log file name is table_store.log. The retry policy is WriteRetryPolicy, which retries the write operation.
ots_client = OTSClient('endpoint', 'access_key_id', 'access_key_secret', 'instance_name', logger_name = 'table_store.log', retry_policy = WriteRetryPolicy())
######### Use STS #########
ots_client = OTSClient('endpoint', 'STS.K8h*******GB77', 'CkuDj******Wn6', 'instance_name', sts_token = 'CAISjgJ1q6Ft5B2y********OFcsLLuw==')
HTTPS is supported from version 2.0.8.
The earliest version of OpenSSL (0.9.8j) is supported, but we recommend OpenSSL 1.0.2d.
The Python 2.0.8 release pack contains a certifi package that can be directly installed and used. To update the root certificate, download the latest root certificate from Root Certificate.