连接和访问从InfluxDB(自托管服务器)到Jupyter Notebook的数据
我一直在尝试通过jupyter笔记本访问InfluxDB自托管数据。 参考链接: https:///www.influxdata。 com/blog/streaming time series-with-jupyter and-influxdb/ 。 从influxdb进口infuxdbclient 从DateTime Import DateTime 从influxdb_client导入OS Import
Import infuxdbclient,Point,WritePrecision 来自influxdb_client.client.write_api导入同步 client = influxdbclient(url =“”,token =令牌,org = org,bucket = bucket = bucket,host = influxdb_host)
代码已成功执行到此处,我一直在尝试在Ref链接中建议的下一步,并且已经获得了一个。尽管我成功地导入了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
这是将自托管数据提取到jupyter笔记本电脑的正确方法吗?还是我一直在研究错误的参考文献。
请提出任何参考链接,以从涌入DB提取自启示的数据到jupyter笔记本。
谢谢, 迪皮卡
I have been trying to access influxdb self hosted data through jupyter notebook.
ref link: https://www.influxdata.com/blog/streaming-time-series-with-jupyter-and-influxdb/
.
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
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论