picar / pyrrd

Automatically exported from code.google.com/p/pyrrd
BSD 3-Clause "New" or "Revised" License
1 stars 0 forks source link

proposal for a query object #21

Open GoogleCodeExporter opened 9 years ago

GoogleCodeExporter commented 9 years ago
in pyrrd, Query object is a mock.

Here is a proposal for a Query object, à la SQLAlchemy :
http://github.com/athoune/Tronche/blob/master/src/tronche/rrd.py

You can first build a Query and using it (r is a RRD object):

query = AVERAGE(resolution=10, start='-10m', column=0, filter = lambda data: (1 
- data))
for ts, value in query(r):
    print ts, value

ts is a datetime object, value a float or None.

Or you can use it inline :

for ts, value in r.fetch('AVERAGE', resolution=5, start='-5m'):
    print ts, value

The code use yield, so, everything is managed as a flow, no array is filled 
then consumed.

If it can help.

Original issue reported on code.google.com by mathieu....@gmail.com on 27 Jan 2010 at 6:51

GoogleCodeExporter commented 9 years ago
Thanks, Mathieu -- I'll take a look at that and see if it's a good fit.

Original comment by duncan.m...@gmail.com on 22 Jun 2011 at 4:03

GoogleCodeExporter commented 9 years ago

Original comment by duncan.m...@gmail.com on 22 Jun 2011 at 4:05