game_players.proto. For more information, please see Creating Table.endpoint, access_id, and access_passwd parameters to create client, which is a TcaplusRestClient object.SetTargetTable method of the client object to specify the table to be accessed.# Create a `TcaplusRestClient` object#endpoint: restful API, such as http://x.x.x.x:80client = TcaplusRestClient(endpoint, access_id, access_passwd)# Use `SetTargetTable` to specify the table to be accessedclient.SetTargetTable(table_group_id=1, table_name='game_players')# Send a data access request. The following uses `AddRecord` as an example:record = {'player_id': 10805514, 'player_name': 'Calvin', 'player_email': 'calvin@test.com', 'game_server_id': 10,'login_timestamp': ['2019-12-12 15:00:00'], 'logout_timestamp': ['2019-12-12 16:00:00'], 'is_online': False, 'pay': {'pay_id': 10101, 'amount': 1000, 'method': 1}}status, resp = client.AddRecord(record, custom_headers=None, return_values=None, table_group_id=None, table_name=None)
SetTargetTable method to specify the target table, you can use the GetTargetTable method to get it.table_group_id, table_name = client.GetTargetTable()
table_group_id and table_name parameters of the API to directly specify the target table. This method will not change the target table set in the SetTargetTable function.status, resp = client.AddRecord(record, custom_headers=None, return_values=None, table_group_id=1, table_name='game_players')
@param keys Dictionary of primary key fields for querying target record, which is required@param select_fields Array of non-primary key field names to be returned, which is optional. You can use a dotted path to specify nested fields@param custom_headers HTTP header to be specified, which is optional@param table_group_id ID of the cluster table group where the table resides, which is optional@param table_name `table_name` of target table, which is optionaldef GetRecord(self, keys, select_fields=[], custom_headers=None, table_group_id=None, table_name=None)
@param record JSON object of the target record to be inserted, which is required@param custom_headers HTTP header to be specified, which is optional@param table_group_id ID of the cluster table group where the table resides, which is optional@param table_name `table_name` of target table, which is optionaldef AddRecord(self, record, custom_headers=None, return_values=None, table_group_id=None, table_name=None)
@param record JSON object of the target record to be set, which is required. This operation involves insertion and modification semantics@param custom_headers HTTP header to be specified, which is optional@param table_group_id ID of the cluster table group where the table resides, which is optional@param table_name `table_name` of target table, which is optionaldef SetRecord(self, record, custom_headers=None, return_values=None, table_group_id=None, table_name=None)
@param record JSON object of the target record to be deleted, which is required. You only need to set a primary key field@param custom_headers HTTP header to be specified, which is optional@param table_group_id ID of the cluster table group where the table resides, which is optional@param table_name `table_name` of target table, which is optionaldef DeleteRecord(self, record, custom_headers=None, return_values=None, table_group_id=None, table_name=None)
pay.amount.@param keys Dictionary of primary key fields for querying target record, which is required@param select_fields Array of non-primary key field names to be returned, which is required. You can use a dotted path to specify nested fields@param custom_headers HTTP header to be specified, which is optional@param table_group_id ID of the cluster table group where the table resides, which is optional@param table_name `table_name` of target table, which is optionaldef FieldGetRecord(self, keys, select_fields, custom_headers=None, table_group_id=None, table_name=None)
pay.amount.@param record JSON object of the target record to be set, which is required. This operation involves insertion and modification semantics@param field_path Array of field names (paths) to be set, which is required. You can use a dotted path to specify nested fields@param custom_headers HTTP header to be specified, which is optional@param table_group_id ID of the cluster table group where the table resides, which is optional@param table_name `table_name` of target table, which is optionaldef FieldSetRecord(self, record, field_path, custom_headers=None, return_values=None, table_group_id=None, table_name=None)
pay.method is 200, the requested value is 50, then the final value will be 250; if the requested value is -50, then the final value will be 150.int32 or int64.@param record Record to be auto-incremented/decremented, which is required. It must contain the primary key, and the target record must be in integer type@param custom_headers HTTP header to be specified, which is optional@param table_group_id ID of the cluster table group where the table resides, which is optional@param table_name `table_name` of target table, which is optionaldef FieldIncRecord(self, record, custom_headers=None, return_values=None, table_group_id=None, table_name=None)
limit and offset to control the size of the packet returned by each request.@param index_keys Dictionary of index keys for querying target record, which is required@param index_name Name of the index for query, which is required@param select_fields Array of non-primary key field names to be returned, which is optional. You can use a dotted path to specify nested fields@param custom_headers HTTP header to be specified, which is optional@param table_group_id ID of the cluster table group where the table resides, which is optional@param table_name `table_name` of target table, which is optional@param limit Maximum number of records to be returned, which is optional@param offset Initial offset of the number of records to be returned, which is optionaldef PartkeyGetRecord(self, index_keys, index_name, select_fields=[], custom_headers=None, table_group_id=None, table_name=None, limit=None, offset=None)
256 KB, and the limit value is subject to the size of one single record. We recommend you set it as follows:limit to 256 KB / record size; for example, if the record size is 10 KB, we recommend you set limit to a value between 20 and 25.limit to 1, i.e., only one record will be returned by one request.limit and offset parameters set, respectively:# Index key settings{'player_id': 39775502, 'player_name': 'Sara'}# The response packet will be as follows if `limit` and `offset` are not set in the request:{u'ErrorCode': 0, u'ErrorMsg': u'Succeed', u'MultiRecords': [{u'RecordVersion': 1, u'Record': {u'logout_timestamp': [u'2019-12-12 16:00:00'], u'player_name': u'Sara', u'login_timestamp': [u'2019-12-12 15:00:00'], u'pay': {u'amount': 100, u'pay_id': 1, u'method': 1}, u'game_server_id': 1, u'player_email': u'sara@test.com', u'is_online': True, u'player_id': 39775502}}, {u'RecordVersion': 1, u'Record': {u'logout_timestamp': [u'2019-12-12 16:10:00'], u'player_name': u'Sara', u'login_timestamp': [u'2019-12-12 15:10:00'], u'pay': {u'amount': 200, u'pay_id': 2}, u'game_server_id': 2, u'player_email': u'sara@163.com', u'is_online': True, u'player_id': 39775502}}, {u'RecordVersion': 1, u'Record': {u'logout_timestamp': [u'2019-12-12 16:20:00'], u'player_name': u'Sara', u'login_timestamp': [u'2019-12-12 15:20:00'], u'pay': {u'amount': 300, u'pay_id': 3, u'method': 1}, u'game_server_id': 3, u'player_email': u'sara@gmail.com', u'is_online': True, u'player_id': 39775502}}], u'RemainNum': 0, u'TotalNum': 3}# The response packet will be as follows if `limit` and `offset` are set in the request and `limit` is set to 2:{u'ErrorCode': 0, u'ErrorMsg': u'Succeed', u'MultiRecords': [{u'RecordVersion': 1, u'Record': {u'logout_timestamp': [u'2019-12-12 16:00:00'], u'player_name': u'Sara', u'login_timestamp': [u'2019-12-12 15:00:00'], u'pay': {u'amount': 100, u'pay_id': 1, u'method': 1}, u'game_server_id': 1, u'player_email': u'sara@test.com', u'is_online': True, u'player_id': 39775502}}, {u'RecordVersion': 1, u'Record': {u'logout_timestamp': [u'2019-12-12 16:10:00'], u'player_name': u'Sara', u'login_timestamp': [u'2019-12-12 15:10:00'], u'pay': {u'amount': 200, u'pay_id': 2}, u'game_server_id': 2, u'player_email': u'sara@163.com', u'is_online': True, u'player_id': 39775502}}], u'RemainNum': 1, u'TotalNum': 3}
limit and offset are set, the number of entries in the returned result will be the same as that set in limit.
To get the full index data, you can judge whether the obtained data is complete based on the RemainNum and TotalNum flags returned in the response packet.Feedback