在python中使用XDB客户端-错误:';InfluxDBClient';对象没有属性';创建#u数据库'/';获取"列表"数据库';

在python中使用XDB客户端-错误:';InfluxDBClient';对象没有属性';创建#u数据库'/';获取"列表"数据库';,python,database,dataframe,influxdb,influxdb-python,Python,Database,Dataframe,Influxdb,Influxdb Python,我刚刚开始在python中使用XDB客户机。我可能做错了什么,但我还没弄明白 from influxdb import InfluxDBClient, DataFrameClient client=InfluxDBClient(host="localhost",port="8086", username='root') client.create_database("TEST") 我得到以下错误: ConnectionError:

我刚刚开始在python中使用XDB客户机。我可能做错了什么,但我还没弄明白

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'))
ConnectionError:HTTPConnectionPool(host='localhost',port=8086):url超过最大重试次数:/query?q=CREATE+DATABASE+%22TEST%22(由NewConnectionError引起(':未能建立新连接:[WinError 10061]无法建立连接,因为目标计算机主动拒绝了它)
你能告诉我我做错了什么吗?还有一个命令行,我可以使用它来知道我想要访问的远程主机的
令牌/url
令牌/url
是什么。
谢谢

您在导入时出错了。 InfluxDBClient应该从influxdb导入。 比如:

从influxdb导入InfluxDBClient

此外,构造函数
InfluxDBClient()
不接受名为
url
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()

嗨@fayez,谢谢你的回答。我做了一些更改,但现在我有一个新错误,我将编辑我的答案,向您显示新错误@fayezdid you install influxdb??另外,请告诉我您的操作系统@Thephoenix Nevermind,谢谢:)在运行代码之前,我必须先运行influxd.exe,它才能正常工作!这就是我要给你的建议!