Skip to content

daq-tools/pyinfluxql

Repository files navigation

PyInfluxQL

About

A query generator for the SQL dialect of the Influx Query Language (InfluxQL). Like SQLAlchemy but for InfluxDB. Consider this an experimental WIP.

Synopsis

from influxdb import InfluxDBClient
from pyinfluxql import Engine, Query, Mean

client = InfluxDBClient('localhost', 8086, 'root', 'root', 'example')
engine = Engine(client)
query = Query(Mean('value')).from_('cpu_load') \
    .where(time__gt=datetime.now() - timedelta(1))
    .group_by(time=timedelta(hours=1))
engine.execute(query)

Tests

How to invoke the test suite.

Using Tox

Run InfluxDB within Docker:

docker run -it --rm --publish 8086:8086 influxdb:1.8.3

Run tox:

tox

Using sandbox

Alternatively, setup package in development mode:

python3 -mvenv .venv
source .venv/bin/activate
pip install --editable=.[test]

Run pytest:

pytest tests -vvv

Credits

Thanks a stack to the original author Jeremiah Malina for his excellent work as well as Michael Pérez for adding integration tests, timezone support and for improving the documentation.

About

A SQL query generator for InfluxDB

Resources

License

Stars

Watchers

Forks

Languages