0

我在这里找到了它的文档。我安装了 PHP SDK。现在,当我浏览文档时,没有太多关于 PHP 的详细信息。我有以下问题:

  1. 在这里我如何指定 $client
$result = $client->createDatabase([
    'DatabaseName' => '<string>', // REQUIRED
    'KmsKeyId' => '<string>',
    'Tags' => [
        [
            'Key' => '<string>', // REQUIRED
            'Value' => '<string>', // REQUIRED
        ],
        // ...
    ],
]);
  1. 是否有任何关于 PHP 时间流的好文档或视频,我可以从中获得一些帮助。
4

2 回答 2

0

下面是一个示例 Timestream 客户端和查询。

// Create client
$client = new \Aws\TimestreamQuery\TimestreamQueryClient([    
    'version' => 'latest',
    'region' => AWS_REGION,  /* eg: eu-west-1 */
    'endpoint' => AWS_TIMESTREAM_ENDPOINT, /* eg: https://query-cell3.timestream.eu-west-1.amazonaws.com */
    'credentials' => new \Aws\Credentials\Credentials(AWS_KEY, AWS_SECRET)
]);

// Perform a basic query with the client
$client->query([
    'QueryString' => 'select * from "db_timestream"."tbl_usage_logs"', 
    'ValidateOnly' => true,
]);

如果您收到端点警告,例如“当前无法检索此服务所需的端点”

您可以使用 AWS CLI 命令查找终端节点,

aws timestream-query describe-endpoints --region eu-west-1

示例响应:

{
    "Endpoints": [
        {
            "Address": "query-cell3.timestream.eu-west-1.amazonaws.com",
            "CachePeriodInMinutes": 1440
        }
    ]
}

可以用类似的方式创建 TimestreamWriteClient 并写入记录。

于 2022-01-30T12:26:34.550 回答
0

有两个客户端类。一种用于写作,一种用于阅读。

TimestreamWriteClient

https://docs.aws.amazon.com/aws-sdk-php/v3/api/class-Aws.TimestreamWrite.TimestreamWriteClient.html

时间流查询客户端

https://docs.aws.amazon.com/aws-sdk-php/v3/api/class-Aws.TimestreamQuery.TimestreamQueryClient.html

您可以在 $sdk 对象上使用函数 createTimestreamQuery 和 createTimestreamWrite 来实例化这些类。

于 2020-12-16T14:55:25.190 回答