如何使用Python客户端将 query 参数绑定到InfluxDB查询?
例如,我希望通过InfluxDb
标签“ my_tag”过滤查询的结果:some_id=5
SELECT * FROM "foobar" WHERE ("my_tag"=some_id);
client = InfluxDBClient(host=my_host,port=my_port)
client.switch_database(database=my_database)
def get_results_by_id(my_id):
results = client.query(
query='SELECT * FROM "foobar" WHERE ("my_tag" = id)',
params={"id": my_id}
)
...
)
得到零结果。显然,我只能使用字符串格式化程序,但是必须有一种使用Influx API的方法。
答案 0 :(得分:0)
client = InfluxDBClient(host=my_host,port=my_port)
client.switch_database(database=my_database)
def get_results_by_id(my_id):
results = client.query(
query='SELECT * FROM foobar WHERE my_tag=$my_tag;',
params={"my_tag": my_id}
)
...
)