I just started using Influxdb client for python and I’m kind of lost on how to access influxdb data base (on a remote server) in order to query some data from it and store the imported data in a data frame.
I found in the documentation, the following lines to access influxdb of a remote host and to query the data:
hi @Anaisdg thank you for your answer
I am using InfluxDB version 1.8.2.
I can access a remote server using TeamViewer, there it’s easy for me to access the databases on influxdb.
However I would like to access these databases from my local machine (without logging in on TeamViewer) using the InfluxDB python client. I can get the IP address of the remote server.
But if I try to do this:
from influxdb import InfluxDBClient, DataFrameClient
I get this error:
ConnectionError: HTTPConnectionPool(host=‘169.XXXXXX’, port=8086): Max retries exceeded with url: /query?q=SHOW+DATABASES (Caused by NewConnectionError(’<urllib3.connection.HTTPConnection object at 0x000001FC55786BC8>: Failed to establish a new connection: [WinError 10060] A connection attempt failed because the connected party did not properly respond after a period of time, or established connection failed because connected host has failed to respond’))
Now you should be able to connect (and can get the list of databases). If you can, then to get a dataframe (assuming the measurement is “brushEvents”), use (some variant of) the following code snippet:
result = client.query(query_string, database="pyexample")
df = result["brushEvents"]
The following seems to be true, based upon what I remember (from when I wrote Python code to access remote Influx databases).
The “path” variable is the path from the top level IP/Port (of the remote system) to the influx endpoint, as specified on the system On many systems, this will be https://<remote_ip_address>/influxdb.
If you can access influxdb via a browser, then you will know the path.
You should be able to enter the URL 'https://<ip>/<path>/ping?verbose=true' in a browser address bar to determine if influxdb is responding at the URL “https://<ip>/<path>”. When the influxdb endpoint is https://<ip>/<path>, the URL https://<ip>/<path>/ping?verbose=true will display a web page with the Influxdb version information. The “<path>” between the <ip> and the “ping” is the path to use during initialization of the Python client. If you get an error message (along the lines of “404 page not found”), then you do not have the correct “path”.
At least, that’s my recollection. Hopefully, I got that correct.