influxdata / influxdata/influxdb
The code in setting up with python in influx dB is wrong on "Write data" page
- Dominant language
- Rust
- Stars
- 31.7k
- Forks
- 3.7k
- Avg merge
- 13h 37m
- Merged PRs (30d)
- 8
Description
__Steps to reproduce:__
List the minimal actions needed to reproduce the behaviour.
1. Download and setup InfluxDB on windows
2. Goto setting up with python
3. On the "Write data page, the code given to be copied to clipboard would be wrong as we define the InfluxDB client instance as write_client, but then you are trying to access it using client.

__Expected behaviour:__
The code to be executed and we move on to the next step.
__Actual behaviour:__

It causes a NameError.
__Environment info:__
No new setups, just followed the instructions on the web application.
__Config:__
Copy any non-default config values here or attach the full config as a gist or file.
__Logs:__
(myenv) C:\Users\aster\sem6\Unisys\Federated-Threat-Detection\database>python
Python 3.12.0 (tags/v3.12.0:0fb18b0, Oct 2 2023, 13:03:39) [MSC v.1935 64 bit (AMD64)] on win32
Type "help", "copyright", "credits" or "license" for more information.
>>> import influxdb_client, os, time
>>> from influxdb_client import InfluxDBClient, Point, WritePrecision
>>> from influxdb_client.client.write_api import SYNCHRONOUS
>>>
>>> token = os.environ.get("INFLUXDB_TOKEN")
>>> org = "Threat-detection"
>>> url = "http://localhost:8086"
>>>
>>> write_client = influxdb_client.InfluxDBClient(url=url, token=token, org=org)
>>> bucket="Threat-detection"
>>>
>>> write_api = client.write_api(write_options=SYNCHRONOUS)
Traceback (most recent call last):
File "", line 1, in
NameError: name 'client' is not defined
>>>
__Summary:
Solving this error would allow new users to setup up the db easily and you would retain the users. Also, you would just have to update the code so it's a easy gain, with limited effort.
Contributor guide
Research direction
Start with the Python setup flow and its "Write data" page, using the reported snippet and traceback as the reproduction. Compare the client variable used when creating the InfluxDB client with the variable used by the write API, then verify that the copied example runs without the reported NameError.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- python
- Domain
- documentation
- Issue type
- Bug
- Difficulty
- 1/5
- Estimated time
- Under an hour
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 45/100