https://github.com/daq-tools/pyinfluxql
A SQL query generator for InfluxDB
https://github.com/daq-tools/pyinfluxql
Last synced: 16 days ago
JSON representation
A SQL query generator for InfluxDB
- Host: GitHub
- URL: https://github.com/daq-tools/pyinfluxql
- Owner: daq-tools
- License: mit
- Created: 2019-06-03T19:02:05.000Z (about 7 years ago)
- Default Branch: main
- Last Pushed: 2021-02-14T15:24:42.000Z (over 5 years ago)
- Last Synced: 2025-02-28T09:32:02.673Z (over 1 year ago)
- Language: Python
- Homepage:
- Size: 28.3 KB
- Stars: 1
- Watchers: 2
- Forks: 0
- Open Issues: 1
-
Metadata Files:
- Readme: README.rst
- Changelog: CHANGES.rst
- License: LICENSE
Awesome Lists containing this project
README
##########
PyInfluxQL
##########
.. image:: https://github.com/daq-tools/pyinfluxql/workflows/Tests/badge.svg
:target: https://github.com/daq-tools/pyinfluxql/actions?workflow=Tests
.. image:: https://img.shields.io/pypi/pyversions/pyinfluxql.svg
:target: https://python.org
.. image:: https://img.shields.io/pypi/v/pyinfluxql.svg
:target: https://pypi.org/project/pyinfluxql/
.. image:: https://img.shields.io/pypi/dm/pyinfluxql.svg
:target: https://pypi.org/project/pyinfluxql/
.. image:: https://img.shields.io/pypi/status/pyinfluxql.svg
:target: https://pypi.org/project/pyinfluxql/
.. image:: https://img.shields.io/pypi/l/pyinfluxql.svg
:target: https://pypi.org/project/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.
.. _Influx Query Language (InfluxQL): https://docs.influxdata.com/influxdb/v1.8/query_language/
********
Synopsis
********
.. code-block:: python
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.
.. _Jeremiah Malina: https://github.com/jjmalina
.. _Michael Pérez: https://github.com/puhrez