python - 在 python 中使用 Influxdb 客户端 - 错误:“InfluxDBClient”对象没有属性“create_database”/“get_list_database”
问题描述
我刚开始influxdb
在 python 中使用客户端。我可能做错了什么,但我还无法弄清楚。
from influxdb import InfluxDBClient, DataFrameClient
client=InfluxDBClient(host="localhost",port="8086", username='root')
client.create_database("TEST")
我收到以下错误:
ConnectionError: HTTPConnectionPool(host='localhost', port=8086): Max retries exceeded with url: /query?q=CREATE+DATABASE+%22TEST%22 (Caused by NewConnectionError('<urllib3.connection.HTTPConnection object at 0x0000013E5DD0A8C8>: Failed to establish a new connection: [WinError 10061] No connection could be made because the target machine actively refused it'))
你能告诉我我做错了什么吗?还有一个命令行,我可以使用它来了解我想要访问的远程主机是什么token/url
或远程主机是什么。token/url
谢谢
解决方案
您在导入时犯了一个错误。InfluxDBClient 应该从 influxdb 导入。喜欢:
from influxdb import InfluxDBClient
此外,构造函数InfluxDBClient()
不接受名为url
and的参数token
。根据文档,构造函数是:
InfluxDBClient(host='mydomain.com', port=8086, username='myuser', password='mypass', ssl=True, verify_ssl=True)
所以你的代码应该是这样的:
from influxdb import InfluxDBClient, DataFrameClient
client=InfluxDBClient(host="localhost",port="8086", username='root')
client.create_database("TEST")
client.get_list_database()
推荐阅读
- angular - ./src/polyfills.ts 中的错误未找到模块:错误:无法解析“zone.js/dist/zone”
- swift - 如何在 Swift 中测量 DispatchQueue 并发异步中的代码块执行时间?
- python - 在 Pyspark Rdd 映射函数中传递 python 类对象
- ruby-on-rails - 如何在 Ruby on rails 中创建动态哈希数组
- node.js - 如何将 1 存储为 Double mongoose,mongodb?
- assembly - 使用 SSE4.1 的 8 × 16 位整数向量的高效校验和
- javascript - 加载屏幕时如何将子属性/值传递给父组件
- java - 如何修复构建 Android 中的错误:使用未声明的标识符“V4L2_COM_CMD_FLUSH”
- reactjs - 移动屏幕,屏幕下方可见
- java - 为特定类型的字符寻找正则表达式并且没有重复