TableStoreClient is the client for Table Store. It provides callers with a series of methods for operating tables and reading/writing data from/to a single row or multiple rows.
Determine an endpoint
An endpoint is the domain name address 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,
Region address of Table Store
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 address, which is the endpoint of the instance.
Configure an AccessKey
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, initialize a TableStore.Client instance by following these steps:
Use the endpoint of Table Store to create a client.
// Initialize the "TableStoreClient" instance // endPoint is the Table Store address (for example, "https://instance.cn-hangzhou.ots.aliyun.com:80"), which must start with "https://" // accessKeyId is the AccessKeyID used to access Table Store. // accessKeySecret is the AccessKeySecret used to access Table Store. // instanceName is the name of the instance to access. You can create an instance on the Table Store console func NewClient(endPoint, instanceName, accessKeyId, accessKeySecret string, options ... ClientOption) *TableStoreClient
client = NewClient("your_instance_endpoint", "your_instance_name", "your_user_id", "your_user_key")