查询 SDK 客户端 - Amazon Timestream
Amazon Web Services 文档中描述的 Amazon Web Services 服务或功能可能因区域而异。要查看适用于中国区域的差异,请参阅 中国的 Amazon Web Services 服务入门 (PDF)

有关与适用于 LiveAnalytics 的 Amazon Timestream 类似的功能,可以考虑使用适用于 InfluxDB 的 Amazon Timestream。适用于 InfluxDB 的 Amazon Timestream 提供简化的数据摄取和个位数毫秒级的查询响应时间,以实现实时分析。点击此处了解更多信息。

查询 SDK 客户端

可使用以下代码段创建用于查询 SDK 的 Timestream 客户端。查询 SDK 用于查询存储在 Timestream 中的现有时间序列数据。

注意

这些代码段基于 GitHub 上的完整示例应用程序。有关如何开始使用示例应用程序的更多信息,请参阅 示例应用程序

Java
private static AmazonTimestreamQuery buildQueryClient() { AmazonTimestreamQuery client = AmazonTimestreamQueryClient.builder().withRegion("us-east-1").build(); return client; }
Java v2
private static TimestreamQueryClient buildQueryClient() { return TimestreamQueryClient.builder() .region(Region.US_EAST_1) .build(); }
Go
sess, err := session.NewSession(&aws.Config{Region: aws.String("us-east-1")})
Python
query_client = session.client('timestream-query')
Node.js

以下代码段使用 Amazon SDK for JavaScript v3。有关如何安装客户端和使用情况的更多信息,请参阅 Timestream 查询客户端:Amazon SDK for JavaScript v3

此处显示额外的命令导入。创建客户端不需要 QueryCommand 导入。

import { TimestreamQueryClient, QueryCommand } from "@aws-sdk/client-timestream-query"; const queryClient = new TimestreamQueryClient({ region: "us-east-1" });

以下代码段使用 Amazon SDK for JavaScript V2 风格。该代码段基于示例应用程序,该应用程序位于 GitHub 上的 Node.js 示例适用于 LiveAnalytics 的 Amazon Timestream 应用程序

queryClient = new AWS.TimestreamQuery();
.NET
var queryClientConfig = new AmazonTimestreamQueryConfig { RegionEndpoint = RegionEndpoint.USEast1 }; var queryClient = new AmazonTimestreamQueryClient(queryClientConfig);