This module allows accessing influxdb2 with SQLAlchemy.
Using the DB API:
from influxdb2_dbapi import connect
conn = connect(host='localhost', port=8086,scheme='http',org=..,token=..)
curs = conn.cursor()
curs.execute("""
from(bucket: "...")
...
""")
#or
curs.execute("""
SELECT *
FROM (
from(bucket: "...")
...
)as qry
LIMIT 10
""")
#or
curs.execute("""
from(bucket: "...")
...
""")
#or
curs.execute("""
SELECT *
FROM (
from(bucket: "...")
...
)as qry
LIMIT 10
""")
for row in curs:
print(row)
Using SQLAlchemy:
from sqlalchemy import *
from sqlalchemy.engine import create_engine
from sqlalchemy.schema import *
engine = create_engine('influxdb2://localhost:8086') # uses HTTP by default :(
places = Table('places', MetaData(bind=engine), autoload=True)
print(select([func.count('*')], from_obj=places).scalar())
Using the REPL:
$ influxdb2_db http://localhost:8086/
> from(bucket:...)
cnt
-----
12345
python -m pip install -e .
https://www.turing.com/kb/how-to-create-pypi-packages#how-to-create-and-upload-a-package-to-pypi
sudo apt install twine
python setup.py sdist
twine upload dist/*