influxdb python client working with asyncio
pip install aioinflux3
from aioinflux3 import InfluxClient, Measurement, Query, Field
async with InfluxClient(host=..., port=..., org=..., token=...) as client:
# write code here
async with InfluxClient(host=..., port=..., org=..., token=...) as client:
await client.write(Measurement.new('measurement',
timestamp,
tag=[Field(key=tag key,
val=tag value), ],
fields=[
Field(key=filed key,
val=field value),
]
)
)
async with InfluxClient(host=..., port=..., org=..., token=...) as client:
query = Query(bucket name, measurement=measurement name)
.range(start='-4h', end='-1s')
.filter('_field name', tag name= tag value)
.window(every='5s', fn='func name') # func name in next list
.do_yield(name='func name') # name if optional
resp = await client.query(query) # return json table
resp = await client.query(query, numpy=True) # return a numpy Structured Array
func list:
- mean
- median
- max
- min
- sum
- derivative
- distinct
- count
- increase
- skew
- spread
- stddev
- first
- last
- unique
- sort
- nonnegative derivative1
This project started for own useage. My goal is make it simple and easy to use, it's not full functional for InfluxDB v2 API. If you like it, Pls star, and tell me yourneeds in issuse, I will try my best to make it happen.