### Compile and Install Protobuf Source: https://www.tencentcloud.com/document/product/1016/30287 Compiles the Protobuf source code and installs it to the specified prefix. This step includes compilation, verification, and installation. ```bash make make check make install ``` -------------------------------- ### Navigate to Coroutine Example Directory Source: https://www.tencentcloud.com/document/product/1016/30287 Enter the directory containing C++ PB2 coroutine simple table examples for single operations. This is where you'll find the 'set' API example. ```bash cd TcaplusPbApi3.18.0.152096.x86_64_release_20170712/release/x86_64/examples/tcaplus/C++_pb2_coroutine_simpletable/SingleOperation/set ``` -------------------------------- ### Configure Protobuf Installation Path Source: https://www.tencentcloud.com/document/product/1016/30287 Configures the Protobuf build process, specifying the desired installation directory. It is recommended to install under `/usr/local/protobuf`. ```bash ./configure --prefix=/usr/local/protobuf ``` -------------------------------- ### HTTP GET Request Example Source: https://www.tencentcloud.com/document/product/1016/35019 Example of an HTTP GET request structure for querying Cloud Virtual Machine instances. ```APIDOC ## HTTP GET Request Example ### Request URL ``` https://cvm.tencentcloudapi.com/?Limit=10&Offset=0 ``` ### Request Headers ``` Authorization: TC3-HMAC-SHA256 Credential=AKID********************************/2018-10-09/cvm/tc3_request, SignedHeaders=content-type;host, Signature=5da7a33f6993f0614b047e5df4582db9e9bf4672ba50567dba16c6ccf174c474 Content-Type: application/x-www-form-urlencoded Host: cvm.tencentcloudapi.com X-TC-Action: DescribeInstances X-TC-Version: 2017-03-12 X-TC-Timestamp: 1539084154 X-TC-Region: ap-guangzhou ``` ``` -------------------------------- ### Install Go Environment Source: https://www.tencentcloud.com/document/product/1016/37722 Use this command to install the Go programming language environment on your system. ```bash yum install -y golang ``` -------------------------------- ### Navigate to Example Directory Source: https://www.tencentcloud.com/document/product/1016/30287 Change directory to the common C++ examples for PB2. This is necessary before modifying configuration files. ```bash cd TcaplusPbApi3.36.0.152096.x86_64_release_20170712/release/x86_64/examples/tcaplus/C++_common_for_pb2 ``` -------------------------------- ### Output Example Source: https://www.tencentcloud.com/document/product/1016/35037 Example of a successful API response, showing file information. ```APIDOC ## Output Example ```json { "Response": { "IdlFileInfos": [ { "FileContent": "syntax%3D%22proto2%22%3Bpackage%20myTcaplusTable%3Bimport%20%22tcaplusservice.optionv1.proto%22%3Bmessage%20tb_example%7Boption%28tcaplusservice.tcaplus_primary_key%29%3D%22uin%2Cname%22%3Brequired%20int64%20uin%20%3D%201%3Brequired%20string%20name%20%3D%202%3Brequired%20int32%20gamesvrid%20%3D%203%3Boptional%20string%20logintime%20%3D%204%3B%7D", "FileExtType": "proto", "FileId": 564, "FileName": "tb_example", "FileSize": 266, "FileType": "PROTO" } ], "RequestId": "5d592aa1-ee73-4b5e-90bf-062efcc05966", "TotalCount": 1 } } ``` ``` -------------------------------- ### Create Snapshots Input Example Source: https://www.tencentcloud.com/document/product/1016/40095 This example demonstrates how to construct a POST request to create snapshots. Ensure all common request parameters are included. ```http POST / HTTP/1.1 Host: tcaplusdb.intl.tencentcloudapi.com Content-Type: application/json X-TC-Action: CreateSnapshots { "ClusterId": "xx", "SelectedTables": [ { "SnapshotName": "666", "TableGroupId": "1", "SnapshotTime": "2020-09-22 00:00:00", "TableName": "cl_generic", "SnapshotDeadTime": "2020-09-22 00:00:00" } ] } ``` -------------------------------- ### Verify Protobuf Installation Source: https://www.tencentcloud.com/document/product/1016/30287 Checks if the Protobuf compiler (`protoc`) is installed correctly by displaying its version. A successful output indicates the installation was successful. ```bash # protoc --version libprotoc 2.6.1 ``` -------------------------------- ### Example Authorization Header Source: https://www.tencentcloud.com/document/product/1016/35020 This is an example of a complete Authorization header, formatted according to the specified structure. ```text TC3-HMAC-SHA256 Credential=AKID********************************/2019-02-25/cvm/tc3_request, SignedHeaders=content-type;host, Signature=a7b8551448762bd123d6f79e81815e31a92013640a6cef36a08ad4b292a4d2f2 ``` -------------------------------- ### Example String to Sign Source: https://www.tencentcloud.com/document/product/1016/35020 This is an example of the concatenated string to be signed, based on the specified fields. ```text TC3-HMAC-SHA256 1551113065 2019-02-25/cvm/tc3_request 2815843035062fffda5fd6f2a44ea8a34818b0dc46f024b8b3786976a3adda7a ``` -------------------------------- ### HTTP GET Request Structure with TC3-HMAC-SHA256 Source: https://www.tencentcloud.com/document/product/1016/35019 This example demonstrates the structure of an HTTP GET request using the TC3-HMAC-SHA256 signature algorithm, including common parameters in the URL and headers. ```http https://cvm.tencentcloudapi.com/?Limit=10&Offset=0 Authorization: TC3-HMAC-SHA256 Credential=AKID********************************/2018-10-09/cvm/tc3_request, SignedHeaders=content-type;host, Signature=5da7a33f6993f0614b047e5df4582db9e9bf4672ba50567dba16c6ccf174c474 Content-Type: application/x-www-form-urlencoded Host: cvm.tencentcloudapi.com X-TC-Action: DescribeInstances X-TC-Version: 2017-03-12 X-TC-Timestamp: 1539084154 X-TC-Region: ap-guangzhou ``` -------------------------------- ### Clear Table using GET Request Source: https://www.tencentcloud.com/document/product/1016/35042 Use this example to clear a table by making a GET request to the Tencent Cloud API. Ensure all common request parameters are included. ```http https://tcaplus.tencentcloudapi.com/?Action=ClearTables &ClusterId=5674209986 &SelectedTables.0.TableInstanceId=tcaplus-1f224454 &SelectedTables.0.TableGroupId=101 &SelectedTables.0.TableName=tb_example & ``` -------------------------------- ### Get Table Tags Example Source: https://www.tencentcloud.com/document/product/1016/36902 This example demonstrates how to retrieve table tags using the DescribeTableTags API action. It includes the necessary request parameters and the expected output format. ```http POST / HTTP/1.1 Host: tcaplusdb.intl.tencentcloudapi.com Content-Type: application/json X-TC-Action: DescribeTableTags { "ClusterId": "5674209986", "SelectedTables": [ { "TableIdlType": "xx", "TableGroupId": "1", "FileExtType": "xx", "TableInstanceId": "tcaplus-0xm12ck1", "Memo": "xx", "TableName": "tb_test", "ReservedReadQps": 0, "ListElementNum": 0, "ReservedVolume": 0, "ReservedWriteQps": 0, "FileSize": 0, "FileContent": "xx", "FileName": "xx", "TableType": "xx" } ] } ``` ```json { "Response": { "RequestId": "abd7111a-62d4-4bbb-a781-3646040e9530", "TotalCount": 1, "Rows": [ { "TableInstanceId": "tcaplus-0xm12ck1", "TableGroupId": "1", "TableName": "tb_test", "Tags": { "TagKey": "test1", "TagValue": "value1" } } ] } } ``` -------------------------------- ### HTTP GET Request Structure for Signature Algorithm v1 Source: https://www.tencentcloud.com/document/product/1016/35019 This example shows how to structure an HTTP GET request when using Signature Algorithm v1. Ensure all common parameters are included in the URL query string. ```http https://cvm.tencentcloudapi.com/?Action=DescribeInstances&Version=2017-03-12&SignatureMethod=HmacSHA256&Timestamp=1527672334&Signature=37ac2f4fde00b0ac9bd9eadeb459b1bbee224158d66e7ae5fcadb70b2d181d02&Region=ap-guangzhou&Nonce=23823223&SecretId=AKID******************************** Host: cvm.tencentcloudapi.com Content-Type: application/x-www-form-urlencoded ``` -------------------------------- ### Example1 Getting table tags Source: https://www.tencentcloud.com/document/product/1016/36902 This example demonstrates how to retrieve table tags using the DescribeTableTags API operation. ```APIDOC ## POST / DescribeTableTags ### Description This endpoint retrieves table tags for a specified cluster and tables. ### Method POST ### Endpoint / ### Request Body - **ClusterId** (string) - Required - The ID of the cluster. - **SelectedTables** (array) - Required - A list of tables for which to retrieve tags. - **TableIdlType** (string) - Optional - Type of table ID. - **TableGroupId** (string) - Optional - The ID of the table group. - **FileExtType** (string) - Optional - Type of file extension. - **TableInstanceId** (string) - Optional - The instance ID of the table. - **Memo** (string) - Optional - A memo for the table. - **TableName** (string) - Optional - The name of the table. - **ReservedReadQps** (integer) - Optional - Reserved read QPS. - **ListElementNum** (integer) - Optional - Number of list elements. - **ReservedVolume** (integer) - Optional - Reserved volume. - **ReservedWriteQps** (integer) - Optional - Reserved write QPS. - **FileSize** (integer) - Optional - File size. - **FileContent** (string) - Optional - File content. - **FileName** (string) - Optional - File name. - **TableType** (string) - Optional - The type of the table. ### Request Example ```json { "ClusterId": "5674209986", "SelectedTables": [ { "TableIdlType": "xx", "TableGroupId": "1", "FileExtType": "xx", "TableInstanceId": "tcaplus-0xm12ck1", "Memo": "xx", "TableName": "tb_test", "ReservedReadQps": 0, "ListElementNum": 0, "ReservedVolume": 0, "ReservedWriteQps": 0, "FileSize": 0, "FileContent": "xx", "FileName": "xx", "TableType": "xx" } ] } ``` ### Response #### Success Response (200) - **RequestId** (string) - The ID of the request. - **TotalCount** (integer) - The total number of results. - **Rows** (array) - A list of table tag information. - **TableInstanceId** (string) - The instance ID of the table. - **TableGroupId** (string) - The ID of the table group. - **TableName** (string) - The name of the table. - **Tags** (object) - The tags associated with the table. - **TagKey** (string) - The key of the tag. - **TagValue** (string) - The value of the tag. #### Response Example ```json { "Response": { "RequestId": "abd7111a-62d4-4bbb-a781-3646040e9530", "TotalCount": 1, "Rows": [ { "TableInstanceId": "tcaplus-0xm12ck1", "TableGroupId": "1", "TableName": "tb_test", "Tags": { "TagKey": "test1", "TagValue": "value1" } } ] } } ``` ``` -------------------------------- ### Import Snapshot Request Example Source: https://www.tencentcloud.com/document/product/1016/40092 This example demonstrates how to construct a POST request to import a snapshot. Ensure all common request parameters and the specific API parameters are correctly formatted. ```http POST / HTTP/1.1 Host: tcaplusdb.intl.tencentcloudapi.com Content-Type: application/json X-TC-Action: ImportSnapshots { "ClusterId": "abc", "Snapshots": { "TableGroupId": "abc", "TableName": "abc", "SnapshotName": "abc", "SnapshotTime": "2020-09-22 00:00:00", "SnapshotDeadTime": "2020-09-22 00:00:00" }, "ImportSpecialKey": "abc", "KeyFile": { "FileName": "abc", "FileExtType": "abc", "FileContent": "abc", "FileSize": 0 }, "ImportOriginTable": "abc", "NewTableGroupId": "abc", "NewTableName": "abc" } ``` -------------------------------- ### Main Function Example Source: https://www.tencentcloud.com/document/product/1016/38818 This is a sample main function demonstrating the workflow of initializing the API client, sending a replace request, and receiving the response. ```APIDOC ## Main Function Example ### Description Demonstrates the complete workflow of initializing the TcaplusDB API client, sending a replace request, and receiving the response. ### Method C++ function call ### Endpoint N/A (Client-side SDK function) ### Parameters N/A ### Request Example ```cpp int main(void) { // Initialize the log int ret = InitLog(); if ( ret != 0) { printf("init log failed\n"); return -1; } // Initialize the API client ret = InitServiceAPI(); if ( ret != 0) { printf("init InitServiceAPI failed\n"); return -1; } // Send the request ret = SendReplaceRequest(); if (0 != ret) { printf("SendReplaceRequest failed\n"); return -1; } // Receive the response TcaplusServiceResponse* response = NULL; ret = RecvResp(response); if (0 != ret) { printf("RecvResp failed\n"); return -1; } // Get the result, where "0" indicates success int32_t result = response->GetResult(); if (0 != result) { printf("the result is %d\n", result); return -1; } return 0; } ``` ``` -------------------------------- ### Get Associated Tag List of a Table Group Source: https://www.tencentcloud.com/document/product/1016/36900 Use this example to retrieve the associated tag list for a specific table group. Ensure common request parameters are included. ```http POST / HTTP/1.1 Host: tcaplusdb.intl.tencentcloudapi.com Content-Type: application/json X-TC-Action: DescribeTableGroupTags { "ClusterId": "5674209986", "TableGroupIds": [ "1" ] } ``` -------------------------------- ### Install TcaplusDB SDK Source: https://www.tencentcloud.com/document/product/1016/30287 Installs the TcaplusDB SDK by extracting the downloaded package to a specified directory on the development server. Replace placeholders with actual paths. ```bash tar –xzf -C , ``` -------------------------------- ### Clear Table using POST Request Source: https://www.tencentcloud.com/document/product/1016/35042 This example demonstrates how to clear a table using a POST request with a JSON payload. It's suitable for more complex requests or when preferred over GET. ```http POST / HTTP/1.1 Host: tcaplusdb.intl.tencentcloudapi.com Content-Type: application/json X-TC-Action: ClearTables { "ClusterId": "19090249266", "SelectedTables": [ { "TableGroupId": "1", "TableName": "auto_proto2_gene_0_27110510", "TableIdlType": "TDR", "TableType": "GENERIC" } ] } ``` -------------------------------- ### Run TcaplusDB SDK Demo Source: https://www.tencentcloud.com/document/product/1016/37724 Execute the `demo.php` script to quickly try out TcaplusDB SDK features. Comment out unneeded functions before running. ```bash php -f "demo.php" ``` -------------------------------- ### Run TcaplusDB Example Binary Source: https://www.tencentcloud.com/document/product/1016/30287 Execute the compiled program using './mytest'. The results will be displayed on the standard output. Check 'tcaplus_pb.log' for errors. ```bash ./mytest ``` -------------------------------- ### Set Environment Variables and Run Script Source: https://www.tencentcloud.com/document/product/1016/30287 Source the environment configuration file to set necessary variables, then execute the conversion script. This prepares the environment for compilation. ```bash source envcfg.env bash conv.sh ``` -------------------------------- ### Example API Output Source: https://www.tencentcloud.com/document/product/1016/35049 This is an example of a successful API response structure. ```json { "Response": { "RequestId": "87562838-1eda-45f3-abda-59a704135fe7" } } ``` -------------------------------- ### Initialize TcaplusDB API and Send Delete Request Source: https://www.tencentcloud.com/document/product/1016/38815 This sample `main` function shows the complete process of initializing the TcaplusDB asynchronous Protobuf API, sending a delete request, and processing the response. It includes necessary network updates and a loop for receiving responses. ```cpp int main(void) { // Initialize the API client int ret = InitAsyncPbApi(); if ( ret != 0) { printf("InitAsyncPbApi failed\n"); return -1; } // Send the request ret = SendDelRequest(); if (0 != ret) { printf("SendDelRequest failed\n"); return -1; } // Receive the response do { // Update and receive the response packet g_stAsyncApi.UpdateNetwork(); usleep(1000 * 10); } while (g_dwTotalRevNum != 1); return 0; } ``` -------------------------------- ### Send TcaplusAPI Get Request Source: https://www.tencentcloud.com/document/product/1016/38819 Sends a get request to the TcaplusAPI. This involves creating a request object, initializing it for a get operation, adding a record with key information, and then sending the request. ```cpp int32_t SendGetRequest() { // Request object class TcaplusService::TcaplusServiceRequest* pstRequest = g_stTcapSvr.GetRequest(TABLE_NAME); if (NULL == pstRequest) { tlog_error(g_pstLogHandler, 0, 0, "g_stTcapSvr.GetRequest(%s) failed.", TABLE_NAME); return -1; } // Initialize the request object int iRet = pstRequest->Init(TCAPLUS_API_GET_REQ, NULL, 0, 0, 0, 0); if(0 != iRet) { tlog_error(g_pstLogHandler, 0, 0, "pstRequest->Init(TCAPLUS_API_GET_REQ) failed, iRet: %d.", iRet); return iRet; } // Add a record to the table according to the request TcaplusService::TcaplusServiceRecord* pstRecord = pstRequest->AddRecord(); if (NULL == pstRecord) { tlog_error(g_pstLogHandler, 0, 0, "pstRequest->AddRecord() failed."); return -1; } PLAYERONLINECNT stPLAYERONLINECNT; memset(&stPLAYERONLINECNT, 0, sizeof(stPLAYERONLINECNT)); // Specify the information of the key to be queried stPLAYERONLINECNT.dwTimeStamp = 1; snprintf(stPLAYERONLINECNT.szGameSvrID, sizeof(stPLAYERONLINECNT.szGameSvrID), "%s", "mysvrid"); // Set the record based on the TDR description iRet = pstRecord->SetData(&stPLAYERONLINECNT, sizeof(stPLAYERONLINECNT)); if(0 != iRet) { tlog_error(g_pstLogHandler, 0, 0, "pstRecord->SetData() failed, iRet: %d.", iRet); return iRet; } // Send the request packet iRet= g_stTcapSvr.SendRequest(pstRequest); if(0 != iRet) { tlog_error(g_pstLogHandler, 0, 0, "g_stTcapSvr.SendRequest failed, iRet: %d.", iRet); return iRet; } return 0; } ``` -------------------------------- ### Compile TcaplusDB Example Binary Source: https://www.tencentcloud.com/document/product/1016/30287 Run the 'make' command to compile the example code. This will generate an executable file named 'mytest' upon successful compilation. ```bash make ``` -------------------------------- ### Sample Update Command Execution Source: https://www.tencentcloud.com/document/product/1016/38799 This is an example of executing the 'update' command with specific values for level, count, and keys, demonstrating a successful update operation and the time taken. ```bash tcaplus> update table_list set level=99 and count= 88 where uin=99 and name = "99" and key1=99 and -index=0;  update success  update time: 117086 us ``` -------------------------------- ### TcaplusDB 'show tables' Sample Output Source: https://www.tencentcloud.com/document/product/1016/38795 Example output of the 'show tables' command, displaying table names, types (GENERIC or LIST), and protocols (TDR or PROTOBUF). ```text ---------------------------------------------------------- | Table Name Type Protocol | ---------------------------------------------------------- | test_table GENERIC TDR | | tbMailTest LIST PROTOBUF | | pb_generic_index_shardingkey GENERIC PROTOBUF | | pb_generic_index_noshardkey GENERIC PROTOBUF | | pb_generic_noindex_noshardkey GENERIC PROTOBUF | | pb_list LIST PROTOBUF | | pb_list2 LIST PROTOBUF | | pb_sortedlist LIST PROTOBUF | | aes_info GENERIC TDR | | auth_info GENERIC TDR | | depend_me_services GENERIC TDR | | host_info GENERIC TDR | | instance_info GENERIC TDR | | node_info GENERIC TDR | | service_depends GENERIC TDR | | service_info GENERIC TDR | | token_info GENERIC TDR | | cl_list LIST PROTOBUF | | cl_generic GENERIC PROTOBUF | | table_generic GENERIC TDR | ---------------------------------------------------------- ``` -------------------------------- ### Example API Output Source: https://www.tencentcloud.com/document/product/1016/35052 This is an example of a successful API response, showing the RequestId and TaskId. ```json { "Response": { "RequestId": "abd7111a-62d4-4bbb-a781-3646040e9530", "TaskId": "6179109757-1210" } } ``` -------------------------------- ### Initialize TcaplusAPI Client Source: https://www.tencentcloud.com/document/product/1016/38820 Initializes the Tcaplus server client, adds directory server addresses, retrieves table meta information, registers the table, and connects to TcaplusDB proxy servers. Ensure APP_ID, ZONE_ID, SIGNATURE, DIR_URL_COUNT, DIR_URL_ARRAY, TABLE_NAME, and g_szMetalib_tcaplus_tb are defined. ```cpp // The client main class of the TCaplus service API TcaplusService::TcaplusServer g_stTcapSvr; // Meta information for the table extern unsigned char g_szMetalib_tcaplus_tb[]; LPTDRMETA g_szTableMeta = NULL; int32_t InitServiceAPI() { // Initialize int32_t iRet = g_stTcapSvr.Init(g_pstTlogger, /*module_id*/0, /*app id*/APP_ID, /*zone id*/ZONE_ID, /*signature*/SIGNATURE); if (0 != iRet) { tlog_error(g_pstLogHandler, 0, 0, "g_stTcapSvr.Init failed, iRet: %d.", iRet); return iRet; } // Add the directory server for (int32_t i = 0; i< DIR_URL_COUNT; i++) { iRet = g_stTcapSvr.AddDirServerAddress(DIR_URL_ARRAY[i]); if (0 != iRet) { tlog_error(g_pstLogHandler, 0, 0, "g_stTcapSvr.AddDirServerAddress(%s) failed, iRet: %d.", DIR_URL_ARRAY[i], iRet); return iRet; } } // Get the meta description of the table g_szTableMeta = tdr_get_meta_by_name((LPTDRMETALIB)g_szMetalib_tcaplus_tb, TABLE_NAME); if(NULL == g_szTableMeta) { tlog_error(g_pstLogHandler, 0, 0,"tdr_get_meta_by_name(%s) failed.", TABLE_NAME); return -1; } // Register the data table (connect to the directory server, verify the password, and get the table routing) with 10-second timeout period iRet = g_stTcapSvr.RegistTable(TABLE_NAME, g_szTableMeta, /*timeout_ms*/10000); if(0 != iRet) { tlog_error(g_pstLogHandler, 0, 0, "g_stTcapSvr.RegistTable(%s) failed, iRet: %d.", TABLE_NAME, iRet); return iRet; } // Connect to all TcaplusDB proxy servers corresponding to the table iRet = g_stTcapSvr.ConnectAll(/*timeout_ms*/10000, 0); if(0 != iRet) { tlog_error(g_pstLogHandler, 0, 0, "g_stTcapSvr.ConnectAll failed, iRet: %d.", iRet); return iRet; } return 0; } ``` -------------------------------- ### Enable data subscription for tables (Input Example) Source: https://www.tencentcloud.com/document/product/1016/42590 This example demonstrates how to enable data subscription for tables and configure feature settings using the SetTableDataFlow API. It includes parameters for table details, primary keys, field types, and Kafka integration. ```HTTP https://tcaplusdb.intl.tencentcloudapi.com/?Action=SetTableDataFlow &ClusterId=5674209986 &SelectedTables.0.TableInstanceId=tcaplus-1f224454 &SelectedTables.0.TableGroupId=101 &SelectedTables.0.TableName=tb_example &SelectedTables.0.TableIdlType=PROTO &SelectedTables.0.TableType=GENERIC &SelectedTables.0.ShardNum=3 &SelectedTables.0.SelectedFields.0.FieldName=name &SelectedTables.0.SelectedFields.0.IsPrimaryKey=Yes &SelectedTables.0.SelectedFields.0.FieldType=string &SelectedTables.0.SelectedFields.0.FieldSize=64 &SelectedTables.0.SelectedFields.1.FieldName=id &SelectedTables.0.SelectedFields.1.IsPrimaryKey=No &SelectedTables.0.SelectedFields.1.FieldType=int32 &SelectedTables.0.SelectedFields.1.FieldSize=4 &SelectedTables.0.KafkaInfo.Address=string &SelectedTables.0.KafkaInfo.IsVpc=0 &SelectedTables.0.KafkaInfo.Topic=string &SelectedTables.0.KafkaInfo.User=string &SelectedTables.0.KafkaInfo.Password=string &SelectedTables.0.KafkaInfo.Instance=string & ``` -------------------------------- ### ModifyCensorship API Response Example Source: https://www.tencentcloud.com/document/product/1016/40656 This is an example of a successful JSON response from the ModifyCensorship API operation. ```json { "Response": { "Uins": [ "xx" ], "ClusterId": "xx", "RequestId": "xx", "Censorship": 0 } } ``` -------------------------------- ### JSON Response Data Example Source: https://www.tencentcloud.com/document/product/1016/37721 This is an example of a JSON response structure for a single record query. ```json { "ErrorCode": 0, "ErrorMsg": "Succeed", "RecordVersion": 9, "ReturnValues": "aaaaaaaaaa", "Record": { "name": "calvinshao", "pay": { "total_money": 11999, "auth": { "update_time": 921 } }, "region": 101, "uin": 100, "gamesvrid": 4101, "logintime": 98 } } ``` -------------------------------- ### Initialize TcaplusAPI Client Source: https://www.tencentcloud.com/document/product/1016/38819 Initializes the TcaplusAPI client, registers the data table, and connects to TcaplusDB proxy servers. Ensure APP_ID, ZONE_ID, SIGNATURE, DIR_URL_ARRAY, and TABLE_NAME are correctly defined. ```cpp int32_t InitServiceAPI() { // Initialize int32_t iRet = g_stTcapSvr.Init(g_pstTlogger, /*module_id*/0, /*app id*/APP_ID, /*zone id*/ZONE_ID, /*signature*/SIGNATURE); if (0 != iRet) { tlog_error(g_pstLogHandler, 0, 0, "g_stTcapSvr.Init failed, iRet: %d.", iRet); return iRet; } // Add the directory server for (int32_t i = 0; i< DIR_URL_COUNT; i++) { iRet = g_stTcapSvr.AddDirServerAddress(DIR_URL_ARRAY[i]); if (0 != iRet) { tlog_error(g_pstLogHandler, 0, 0, "g_stTcapSvr.AddDirServerAddress(%s) failed, iRet: %d.", DIR_URL_ARRAY[i], iRet); return iRet; } } // Get the meta description of the table g_szTableMeta = tdr_get_meta_by_name((LPTDRMETALIB)g_szMetalib_tcaplus_tb, TABLE_NAME); if(NULL == g_szTableMeta) { tlog_error(g_pstLogHandler, 0, 0,"tdr_get_meta_by_name(%s) failed.", TABLE_NAME); return -1; } // Register the data table (connect to the directory server, verify the password, and get the table routing) with 10-second timeout period iRet = g_stTcapSvr.RegistTable(TABLE_NAME, g_szTableMeta, /*timeout_ms*/10000); if(0 != iRet) { tlog_error(g_pstLogHandler, 0, 0, "g_stTcapSvr.RegistTable(%s) failed, iRet: %d.", TABLE_NAME, iRet); return iRet; } // Connect to all TcaplusDB proxy servers corresponding to the table iRet = g_stTcapSvr.ConnectAll(/*timeout_ms*/10000, 0); if(0 != iRet) { tlog_error(g_pstLogHandler, 0, 0, "g_stTcapSvr.ConnectAll failed, iRet: %d.", iRet); return iRet; } return 0; } ``` -------------------------------- ### AddRecord Operation Example Source: https://www.tencentcloud.com/document/product/1016/37725 An example of using the AddRecord method to insert data into a TcaplusDB table. ```APIDOC ## AddRecord Operation Example ### Description This snippet demonstrates how to use the `AddRecord` method to send a data access request to add a record to the specified table. ### Code ```python # Record data to be added 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}} # Send the AddRecord request status, resp = client.AddRecord(record, custom_headers=None, return_values=None, table_group_id=None, table_name=None) ``` ``` -------------------------------- ### Get All Commands and Usage with help Source: https://www.tencentcloud.com/document/product/1016/38793 Use this command to list all available commands and their general usage instructions within the TcaplusDB client tool. ```bash help; ``` -------------------------------- ### ModifyTableMemos API Example Source: https://www.tencentcloud.com/document/product/1016/35034 This example demonstrates how to modify table remarks using the ModifyTableMemos API. ```APIDOC ## ModifyTableMemos ### Description Modifies table remarks for a specified table. ### Method POST ### Endpoint https://tcaplus.tencentcloudapi.com/ ### Parameters #### Query Parameters - **Action** (string) - Required - Specifies the API action to perform, which is "ModifyTableMemos". - **ClusterId** (string) - Required - The ID of the cluster. - **TableMemos.0.TableInstanceId** (string) - Required - The instance ID of the table. - **TableMemos.0.TableGroupId** (string) - Required - The group ID of the table. - **TableMemos.0.TableName** (string) - Required - The name of the table. - **TableMemos.0.Memo** (string) - Required - The remarks to be modified for the table. - **** - Required - Includes authentication and region information. ### Request Example ``` https://tcaplus.tencentcloudapi.com/?Action=ModifyTableMemos &ClusterId=5674209986 &TableMemos.0.TableInstanceId=tcaplus-1f224454 &TableMemos.0.TableGroupId=101 &TableMemos.0.TableName=tb_example &TableMemos.0.Memo=pbTest table1xx & ``` ### Response #### Success Response (200) - **Response** (object) - The response object. - **RequestId** (string) - The ID of the request. - **TableResults** (array) - An array of results for each table modified. - **Error** (object) - Error details if the operation failed for this table. - **TableGroupId** (string) - The group ID of the table. - **TableIdlType** (string) - The IDL type of the table. - **TableInstanceId** (string) - The instance ID of the table. - **TableName** (string) - The name of the table. - **TableType** (string) - The type of the table. - **TaskId** (string) - The task ID for the operation. - **TaskIds** (array) - An array of task IDs for the operation. - **TotalCount** (integer) - The total number of tables processed. #### Response Example ```json { "Response": { "RequestId": "c3446e81-4d07-4a80-a07f-f34f94b598bc", "TableResults": [ { "Error": null, "TableGroupId": "101", "TableIdlType": null, "TableInstanceId": "tcaplus-1f224454", "TableName": "tb_example", "TableType": "PROTO", "TaskId": null, "TaskIds": null } ], "TotalCount": 1 } } ``` ```