Comprehensive Python client library for InfluxDB 2.x with sync/async APIs for writing, querying, and managing time series data.
82
A simple application for logging temperature sensor readings to a time-series database with immediate write confirmation.
Write temperature sensor readings to a time-series database. Each reading should be written immediately and wait for confirmation before proceeding to the next operation.
Given a bucket "sensors" and a measurement name "temperature", write a data point with tag "sensor_id"="sensor_1", field "value"=23.5, and timestamp 1609459200000000000 (nanoseconds). Verify the write completes successfully. @test
Given a bucket "sensors", write three consecutive data points with different sensor IDs (sensor_1, sensor_2, sensor_3) and values (21.0, 22.5, 24.0), each with sequential timestamps. All writes should complete before returning. @test
Control the precision of timestamps when writing data points.
Write a data point with millisecond precision timestamp 1609459200000 (milliseconds), and verify it's correctly stored at that precision level. @test
Write a data point with second precision timestamp 1609459200 (seconds), and verify it's correctly stored at that precision level. @test
@generates
from influxdb_client import InfluxDBClient
from typing import Optional
def write_temperature_reading(
client: InfluxDBClient,
bucket: str,
sensor_id: str,
temperature: float,
timestamp: int,
precision: str = "ns"
) -> None:
"""
Write a single temperature reading to InfluxDB with immediate confirmation.
Args:
client: InfluxDB client instance
bucket: Target bucket name
sensor_id: Unique sensor identifier
temperature: Temperature value in Celsius
timestamp: Unix timestamp in the specified precision
precision: Time precision - "ns", "us", "ms", or "s" (default: "ns")
"""
pass
def write_temperature_batch(
client: InfluxDBClient,
bucket: str,
readings: list[dict]
) -> None:
"""
Write multiple temperature readings sequentially with immediate confirmation for each.
Args:
client: InfluxDB client instance
bucket: Target bucket name
readings: List of dicts with keys 'sensor_id', 'temperature', 'timestamp'
"""
passProvides time-series database client functionality for writing sensor data.
@satisfied-by
Install with Tessl CLI
npx tessl i tessl/pypi-influxdb-clientdocs
evals
scenario-1
scenario-2
scenario-3
scenario-4
scenario-5
scenario-6
scenario-7
scenario-8
scenario-9
scenario-10