This repository was archived by the owner on Oct 29, 2024. It is now read-only.
This repository was archived by the owner on Oct 29, 2024. It is now read-only.
Unexpected behaviour in Python API: time should be in quotes in select #309
Closed
Description
I found that if you are using simple select query "select * from measurement where t = X" without quotes, result becomes unpredictable. For it's unclear why I should use quotes for time, if time is integer (or long).
from time import sleep
from influxdb import client as influxdb
db = influxdb.InfluxDBClient("localhost", 8086, "", "", "queue")
measurement = "wtr"
def drop():
db.query("drop measurement " + measurement)
def show_all():
print db.query("select * from " + measurement)
def check_one_way(t):
result = db.query('select * from {0} where time="{1}"'.format(measurement, t))
return bool(result)
def check_second_way(t):
result = db.query('select * from {0} where time={1}'.format(measurement, t))
return bool(result)
def write_to_influx(exists):
t = 1458239131231000000
points = [{'fields': {'value': 1}, 'time': t, 'measurement': measurement}]
if exists(t):
print "Exists!!!", t
return
db.write_points(points)
sleep(1)
if exists(t):
print "OK" # Expected behaviour
else:
print "WTF?!" # Unexpected behaviour
print "With quotes"
write_to_influx(check_one_way)
show_all()
print "="*80
print "Without quotes"
drop()
write_to_influx(check_second_way)
show_all()
drop()
Metadata
Metadata
Assignees
Labels
No labels