我正在尝试编写以下字符串语句来对 influx db 进行查询:
query=SELECT FIRST("price") ,LAST("price") ,MAX("price") ,MIN("price") ,SUM("amount") FROM "table name" WHERE time >= '2018-05-10T12:02:00Z' AND time <= '2018-06-10T12:03:00Z' GROUP BY time(1h)
但是,由于它在同一个字符串中混合了 " 和 ',因此我无法在 python 中正确解析。
当我尝试:
query='SELECT FIRST("price") ,LAST("price") ,MAX("price") ,MIN("price") ,SUM("amount") FROM "table name" WHERE time >= '2018-05-10T12:02:00Z' AND time <= '2018-06-10T12:03:00Z' GROUP BY time(1h)'
它说由于 ' 在关闭字符串的日期之前导致的无效语法。我也尝试删除或只放置“而不是”,但它没有用。最后我尝试了一些更脏的东西:
query='SELECT FIRST("price") ,LAST("price") ,MAX("price") ,MIN("price") ,SUM("amount") FROM 'tablename' WHERE time >='+"'2018-05-10T12:02:00Z'"+' AND time <= '+"'2018-06-10T12:03:00Z'"+'GROUP BY time(1h)'
但我得到一个空查询。感谢您对此的任何帮助,谢谢。