连接和访问从InfluxDB(自托管服务器)到Jupyter Notebook的数据

发布于 2025-01-25 14:59:56 字数 1428 浏览 4 评论 0原文

我一直在尝试通过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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。
列表为空,暂无数据
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文