0

根据文档,我们可以使用 InfluxDB 直接提供的示例数据。但似乎我不能直接在查询中使用“导入”指令。如何在 Python 中做到这一点?

import influxdb_client

client = influxdb_client.InfluxDBClient(
    url="...",
    token="",
    org=""
)

query = """
import "influxdata/influxdb/sample"

data = sample.data(set: "airSensor")
    |> range(start: -15m)
    |> filter(fn: (r) => r._measurement == "airSensors")
"""

query_api = client.query_api()
df = query_api.query_data_frame(query=query)

下面的代码返回此错误:

ApiException: (500)
Reason: Internal Server Error
HTTP response headers: HTTPHeaderDict({'Content-Type': 'application/json', 'Request-Id': '...', 'X-Influxdb-Build': 'OSS', 'X-Influxdb-Error': 'type error 2:1-2:36: unknown import path: "influxdata/influxdb/sample"', 'X-Influxdb-Version': '1.8.4', 'X-Request-Id': '...', 'Date': 'Thu, 14 Oct 2021 12:24:09 GMT', 'Content-Length': '85'})
HTTP response body: b'{"error":"type error 2:1-2:36: unknown import path: \\"influxdata/influxdb/sample\\""}\n'
4

0 回答 0