Hey ,
I have been trying to access influxdb self hosted data through jupyter notebook.
ref link: Streaming Time Series with Jupyter and InfluxDB | InfluxData
.
from influxdb import InfluxDBClient
from datetime import datetime
import os
from influxdb_client import InfluxDBClient, Point, WritePrecision
from influxdb_client.client.write_api import SYNCHRONOUS
client= InfluxDBClient(url=“”, token=token, org=org,bucket=bucket,host=influxdb_host)
Code has been sucessfully executed upto here and i have been trying the next step suggested in the ref link and have been getting an import error for stream although i have sucessfully imported hvplot.
def source_data(auto_refresh: int, query: str, sink: Stream):
rx \
.interval(period=timedelta(seconds=auto_refresh)) \
.pipe(ops.map(lambda start: f'from(bucket: "my-bucket") '
f'|> range(start: -{auto_refresh}s, stop: now()) '
f'{query}')) \
.pipe(ops.map(lambda query: client.query_api().query_data_frame(query, data_frame_index=['_time']))) \
.pipe(ops.map(lambda data_frame: data_frame.drop(columns=['result', 'table']))) \
.subscribe(observer=lambda data_frame: sink.emit(data_frame), on_error=lambda error: print(error))
pass
Is this the right way to extract the self hosted data to jupyter notebook ? or have I been looking into the wrong references.
Please suggest any reference links to extract selfhosted data from influx db to jupyter notebook.
Thanks,
Deepika