I am trying access the InfluxDB remotely from a Linux
box. When i use the CURL command, i'm able to get the database details -
curl http://xx.xxx.xx.xxx:8086/query --data-urlencode "q=SHOW DATABASES"
{"results":[{"statement_id":0,"series":[{"name":"databases","columns":["name"],"values":[["_internal"],["ExampleDatabase"]]}]}]}
When the same is tried using Requests
Python, I get 404 page not found
import requests
shorturl = 'http://xx.xxx.xx.xxx:8086/query --data-urlencode "q=SHOW DATABASES"'
r = requests.get(shorturl)
print (r.text)
Is there anything that has to be passed to make it work from Python. When i try to hit the URL - http://xx.xxx.xx.xxx:8086/query --data-urlencode "q=SHOW DATABASES" in the browser, i get the 404 message. Telnet from Linux box to the box where InfluxDB is hosted is working.
Python v2.7.5. I tried all the possible ways given over the internet but none of them worked.
Kindly clarify
As i was saying on the comments, your short url with --data-urlencode which is correct for curl is not valid for python requests, please try this,
payload = {'q': 'SHOW DATABASES'}
shorturl = 'http://xx.xxx.xx.xxx:8086/query'
r = requests.get(shorturl, params=payload)
print (r.text)
you can learn more on request here http://docs.python-requests.org/en/master/user/quickstart/