Registry / database / influxdb3-python

influxdb3-python

JSON →
library0.18.0pypypi✓ verified 35d ago

The influxdb3-python library is the community Python client for InfluxDB 3.0 (also known as InfluxDB IOx or InfluxDB Cloud Serverless). It provides a Pythonic interface for writing and querying time-series data using Apache Arrow Flight (gRPC) and InfluxQL/SQL. The current version is 0.18.0, with new releases typically happening monthly or bi-monthly, incorporating new features and bug fixes for integration with InfluxDB 3.0.

databasehttp-networkingdataserialization
Install & Compatibility
Where this runs
tested against v0.20.0 · pip install
no network on importno background threads
Install × environment matrix
Each cell = how many times install + import succeeded across repeated harness runs. Partial = flaky.
glibc = Debian/Ubuntu slim · musl = Alpine Linux
musl
py 3.103.920 runs
installs and imports cleanly · install 0.0s · import 0.658s · 198.4MB
glibc
py 3.103.920 runs
installs and imports cleanly · install 4.0s · import 0.585s · 175MB
183MB installed
● package 183MB
Code
Verified usage

Verified import paths — ran on the pinned version, not inferred.

This client is specifically for InfluxDB 3.0 and uses 'influxdb_client_3' for its package name, distinct from the InfluxDB 2.x client ('influxdb_client').

from influxdb_client_3 import InfluxDBClient3

For InfluxDB 3.0, the `Point` class for data construction is directly available from the top-level `influxdb_client_3` package.

from influxdb_client_3 import Point

Initializes the client, writes a single data point, and then queries data from InfluxDB 3.0. Credentials are sourced from environment variables for secure and flexible deployment. Remember to replace 'YOUR_API_TOKEN' and 'YOUR_DATABASE' or set corresponding environment variables.

import os from influxdb_client_3 import InfluxDBClient3, Point # Ensure these environment variables are set or replace with actual values # Example: export INFLUXDB_V3_HOST="us-east-1-1.aws.cloud2.influxdata.com" HOST = os.environ.get("INFLUXDB_V3_HOST", "us-east-1-1.aws.cloud2.influxdata.com") TOKEN = os.environ.get("INFLUXDB_V3_TOKEN", "YOUR_API_TOKEN") DATABASE = os.environ.get("INFLUXDB_V3_DATABASE", "YOUR_DATABASE") client = InfluxDBClient3(host=HOST, token=TOKEN, database=DATABASE) try: # Write data point = Point("measurement1").tag("tag1", "value1").field("field1", 1.0) client.write(point) print("Data written successfully.") # Query data query = f"SELECT * FROM measurement1 WHERE time > now() - interval '1 hour'" table = client.query(query=query, database=DATABASE) print("\nQuery results:") for row in table: print(row) except Exception as e: print(f"An error occurred: {e}") finally: client.close()
Debug
Known footguns
gotchaThe `org` parameter, which was mandatory in InfluxDB 2.x and earlier `influxdb-client` versions, is no longer required or supported by `influxdb3-python`. Including it can lead to unexpected behavior or errors.
gotchaUsing `write_dataframe()` or `query_dataframe()` methods requires either `pandas` or `polars` to be installed as optional dependencies. If these libraries are not installed, attempting to use these methods will raise an `ImportError`.
gotchaThe `query_async()` method (introduced in v0.12.0) is an `awaitable` coroutine. It must be called with `await` within an `async` function. Calling it directly without `await` will not execute the query and might lead to unexpected behavior or a `RuntimeWarning` if not awaited.
gotchaThe `WriteOptions.no_sync` flag (introduced in v0.14.0) allows for faster writes by not waiting for Write-Ahead Log (WAL) persistence confirmation. While faster, data is not guaranteed to be durable if the server crashes immediately after the write. Default is `False`.
gotchaPrior to version 0.18.0, `InfluxDBClient3.write_file()` and `InfluxDBClient3.write_dataframe()` could fail when batching mode was enabled due to a bug. This was fixed in v0.18.0.
Upgrade
Version history

Breaking-change detection hasn't run for this library yet.

Audit
Security & dependencies

CVE tracking and dependency tree are planned for a later release.

Agent activity
18 hits · last 30 days
gptbot
4
ahrefsbot
4
bytedance
3
script
1
bingbot
1
googlebot
1
Resources