I am trying to query data from the Influx database through pandas using the following code:
from influxdb_client import InfluxDBClient
import pandas as pd
my_token = "my_token"
my_org = "my_org"
bucket = "bucket"
query= '''
from(bucket: "bucket")
|> range(start: v.timeRangeStart, stop: v.timeRangeStop)
|> filter(fn: (r) => r["_measurement"] == "measurement")
|> filter(fn: (r) => r["_field"] == "count")
|> filter(fn: (r) => r["unit"] == "unit")
|> aggregateWindow(every: v.windowPeriod, fn: mean, createEmpty: false)
|> yield(name: "mean")'''
username = 'username'
password = 'password'
client = InfluxDBClient(url="https://us-west-2-1.aws.cloud2.influxdata.com/", token=f'{username}:{password}', org='my_org')
system_stats = client.query_api().query_data_frame(org=my_org, query=query)
After executing the above, I get an error: ApiException: (0) Reason: SSLError [SSL: CERTIFICATE_VERIFY_FAILED] certificate verify failed: unable to get local issuer certificate (_ssl.c:997)
I am not familiar with the Influx database but I need to query some data and create a dataframe. Is the syntax I am using right? How should I fix this? Thank you!
CodePudding user response:
Try with certifi
:
import certifi
client = InfluxDBClient(
url='https://us-west-2-1.aws.cloud2.influxdata.com',
token=f'{username}:{password}', org=my_org,
ssl_ca_cert=certifi.where()
)
Inspired by this github issue
Or use verify_ssl=False
as parameter of InfluxDBClient
but it's not a good idea.