I would like to use the config file generated by running InfluxDB 2.0
influx setup with the Python client’s
InfluxDBClient.from_config_file(). This almost works, but the file produced by
influx setup contains quotation marks around strings and
InfluxDBClient.from_config_file() apparently does not expect the quotation marks. Is this incompatibility expected? Is there a better way to do this? I’m trying to avoid coming up with some separate mechanism for passing the token/org name/etc into my Python client.
Details on what I’m exactly doing:
Run the following (added line breaks for clarity):
influx setup --bucket=telem --name=influx2 # name expected by InfluxDBClient.from_config_file() --org=moms-sewing-room --password=fhqwhgads --username=edgar_jr --force
which creates the file ~/.influxdbv2/configs where the first un-commented section is as below, note the quotation marks around all the strings:
[influx2] url = "http://localhost:8086" token = "7CkNpNw7A6rmeyc_vp0zYPGoOhcZ9zji9C0_RDG1rvb75hQ-JdMyOU81l4SfXJcumH3De1l7O85kODONyzYCKA==" org = "moms-sewing-room" active = true
If I then run
InfluxDBClient.from_config_file('~/.influxdbv2/configs') in Python and try to write points to the bucket I get an error message after it gives up that includes the statement:
Max retries exceeded with url: //localhost:8086%22/api/v2/write?org=%22moms-sewing-room%22&bucket=telem&precision=ns
That’s suspicious. Clearly the URL is missing the “http:” up front, and there are a bunch of “%22” instances scattered around, which is the URL encoding for
". Inspecting the
InfluxDBClient object that was created:
In : logger.influxdb_client.url Out: '"http://localhost:8086"'
Hmmmm. The strings from the config file were captured with the quotation marks included (this applies to token and org as well). If I edit the config file to remove the quotation marks I’m able to write to the database with no problems.
- Ubuntu 20.04
- influxdb2 package version 2.0.4
- influxdb-client version 1.14.0