Hey Guys,
I have a question on running parametrized query on a linux docker container. I see some open Github issues on this topic so it would be great if someone can confirm if this is the right approach:
bind_params = {'start_date': start_date, 'end_date': end_date}
q = "SELECT * FROM new_data WHERE time >= $start_date and time < $end_date"
data = pd.DataFrame(client.query(q, bind_params= bind_params).get_points())
I ran this parametrized query on my python script in my windows machine and it returned the dataframe as expected. I use an influxdb local instance in my windows system.
Executing this same query/python script on a linux docker container returned the error bind_params is not a valid argument.
So, I tried this:
q = "SELECT * FROM new_data WHERE time >= $start_date and time < $end_date"
data = pd.DataFrame(client.query(q, params= {"bind_params" : json.dumps(bind_params)}).get_points())
Error message:
pd.DataFrame(client.query(q, params= bind_params).get_points())
File “/usr/local/lib/python3.8/site-packages/influxdb/client.py”, line 445, in query
response = self.request(
File “/usr/local/lib/python3.8/site-packages/influxdb/client.py”, line 302, in request
raise InfluxDBClientError(response.content, response.status_code)
influxdb.exceptions.InfluxDBClientError: 400: {“error”:“error parsing query: missing parameter: start_date”}
So, I tried this:
q = "SELECT * FROM data WHERE time >= " + start_date +" and time < " + end_date
data = pd.DataFrame(client.query(q).get_points())
I don’t get any errors but I get an empty dataframe. Can someone point out the mistake in this?Thanks!!!