0

How can I bind query parameters to an InfluxDB query using the Python client?

For example, I want the results of a query filtered by the InfluxDb tag "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}
    )
    ...
)

Getting zero results with this. Obviously, I can just use a string formatter, but there must be a way to do it with the Influx API.

1 Answer 1

3
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}
    )
    ...
)
Sign up to request clarification or add additional context in comments.

1 Comment

It's a good style to also use a few words to explain what you did to make it work.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.