In [1]:
import influxdb
import influxalchemy
In [2]:
class Widgets(influxalchemy.Measurement):
__measurement__ = 'widgets'
class Wombats(influxalchemy.Measurement):
__measurement__ = 'wombats'
In [3]:
db = influxdb.DataFrameClient(database="example")
flux = influxalchemy.InfluxAlchemy(db)
In [4]:
flux.query(Widgets)
Out[4]:
In [5]:
flux.query(influxalchemy.Measurement.new("/.*/"))
Out[5]:
In [6]:
flux.query(Widgets.tag1, Widgets.field2)
Out[6]:
In [7]:
flux.query(Widgets | Wombats)
Out[7]:
In [8]:
flux.query(Widgets).filter(Widgets.tag1 == "fizz")
Out[8]:
In [9]:
flux.query(Widgets).filter(Widgets.tag1.like("/z$/"))
Out[9]:
In [10]:
clause1 = Widgets.tag1 == "fizz"
clause2 = Widgets.tag2 == "buzz"
flux.query(Widgets).filter(clause1 & clause2)
Out[10]:
In [11]:
flux.query(Widgets).filter(clause1 | clause2)
Out[11]:
In [12]:
flux.query(Widgets).group_by("time(1d)")
Out[12]:
In [13]:
flux.query(Widgets).group_by(Widgets.tag1)
Out[13]:
In [14]:
flux.query(Widgets).filter(Widgets.time > "now() - 7d")
Out[14]:
In [15]:
flux.query(Widgets).filter(Widgets.time.between("'2016-01-01'", "now() - 7d"))
Out[15]:
In [ ]: