查询带有特殊字符的influxdb



我正在尝试执行。使用python简单地访问influxdb。连接工作得很好,我可以查询几个值。然而,我有一个,报告为homeassistant.autogen.°C。当我试图查询它时,我总是得到

influxdb.exceptions.InfluxDBClientError: 400: {"error":"error parsing query: found u00b0, expected identifier at line 1, char 43"}

使用的代码是:

client = InfluxDBClient(host='192.168.1.x', port=8086, username='user', password='password')
results = client.query(r'SELECT "value" FROM homeassistant.autogen."°C" WHERE entity_id = sensor.x_temperature')

我已经尝试过转义并通过引号传递它,但似乎都不起作用。

我不能改变在influxdb中插入值的方式。

你试过用反斜杠转义吗?

client = InfluxDBClient(host='192.168.1.x', port=8086, username='user', password='password')
results = client.query(r'SELECT "value" FROM homeassistant.autogen.°C WHERE entity_id = sensor.x_temperature')

或包含整个字段名的双引号,例如:

client = InfluxDBClient(host='192.168.1.x', port=8086, username='user', password='password')
results = client.query(r'SELECT "value" FROM "homeassistant.autogen.°C" WHERE entity_id = sensor.x_temperature')

https://docs.influxdata.com/influxdb/v1.8/write_protocols/line_protocol_reference/

最新更新