pythoninfluxdbinfluxdb-python

How connect to locallhost influxdb from python and without token?


I am trying just simple connect to influxdb which started on localhost.

When I try just client:

influx --host 192.168.0.2 --port 8086

It works.

But when I try python:

import os
import json
from influxdb_client import InfluxDBClient, Point, WritePrecision

influxdb_url = os.environ['INFLUXDB_URL']
influxdb_host = os.environ['INFLUXDB_HOST']
influxdb_port = os.environ['INFLUXDB_PORT']

client = InfluxDBClient(url=influxdb_url)

I got exception

TypeError: __init__() missing 1 required positional argument: 'token'

But cli client can not connect without any tokens? Why do I need it in python? What token to use?


Solution

  • InfluxDB 2.0 requires an authentication token for all API access. The client library is using the same APIs as anything else, so it needs a token to securely connect to InfluxDB.

    You can create an auth token from the CLI or the GUI itself.