0

I have a UDP InfluxDB connection:

client = InfluxDBClient(host='localhost', database='adatabase', use_udp=True, udp_port=1234)

Then, I have the following function:

    def getData(self, measurement, field="*", tag="", timeStart=0, timeEnd=0):
    parameters = {"selectedMeasurement": measurement,
                  "selectedField": field}
    print(parameters)
    result = self.client.query('SELECT LAST($selectedField) FROM $selectedMeasurement;', params=parameters)
    print(list(result.get_points()))
    return list(result.get_points())

But I get the following error:

influxdb.exceptions.InfluxDBClientError: 400: {"error":"error parsing query: missing parameter: selectedField"}

I don't understand where the problem is. Also tried with bind_params. I use hardcoded fields and measurements, the code works fine.

1 Answer 1

1

Influxdb allows to use bind_params ($variable) in the WHERE statement, not in SELECT.

Influxdb Docs - Bind Parameter

Sign up to request clarification or add additional context in comments.

Comments

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.