4

I just started using the influxdb client in python. I'm probably doing something wrong but I can't figure it out yet.

from influxdb import InfluxDBClient, DataFrameClient  
client=InfluxDBClient(host="localhost",port="8086", username='root')
client.create_database("TEST")

I get the following errors:

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'))

Could you please tell me what I'm doing wrong ? Also is there a command line that I can use to know what's my token/url or what's the token/url of a remote host I would like to access. Thanks

1 Answer 1

4

you are making a mistake while importing. InfluxDBClient should be imported from influxdb. like:

from influxdb import InfluxDBClient

also, constructor InfluxDBClient() takes no argument named url and token. as per the doc, the constructor is:

InfluxDBClient(host='mydomain.com', port=8086, username='myuser', password='mypass', ssl=True, verify_ssl=True)

so your code should be like this:

from influxdb import InfluxDBClient, DataFrameClient  
 
client=InfluxDBClient(host="localhost",port="8086", username='root')
client.create_database("TEST")
client.get_list_database()
Sign up to request clarification or add additional context in comments.

6 Comments

Hi @fayez, thanks for the answer. I made some changes but now I have a new error
I will edit my answer to show you the new error @fayez
did you install influxdb?? also do tell me your operating system @thephoenix
nevermind, thanks :) I had to run influxd.exe before running the code for it to work
its okay! thats what I was about to suggest you!
|

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.