Python and InfluxDB

Build IoT, analytics, and cloud applications using the Python client library with InfluxDB.

Why use the InfluxDB Python Client Library?

InfluxDB is an API-first time series database for your Python applications. Use the InfluxDB open-source Python API client to write and query data into your applications and even manage your InfluxDB instance from within your app.

Key features

Get started

Batching Data with the InfluxDB's Python Client Library

Querying Data with InfluxDB's Python Client Library

Using the InfluxDB Python Client Library Administrative APIs

 from influxdb_client import InfluxDBClient url = 'https://us-west-2-1.aws.cloud2.influxdata.com' token = 'my-token' org = 'my-org' bucket = 'my-bucket' with InfluxDBClient(url=url, token=token, org=org) as client: query_api = client.query_api() tables = query_api.query('from(bucket: "my-bucket") |> range(start: -1d)') for table in tables: for record in table.records: print(str(record["_time"]) + " - " + record.get_measurement() + " " + record.get_field() + " code-section target2">  
 from datetime import datetime from influxdb_client import WritePrecision, InfluxDBClient, Point from influxdb_client.client.write_api import SYNCHRONOUS url = 'https://us-west-2-1.aws.cloud2.influxdata.com' token = 'my-token' org = 'my-org' bucket = 'my-bucket' with InfluxDBClient(url=url, token=token, org=org) as client: p = Point("weatherstation") \ .tag("location", "San Francisco") \ .field("temperature", 25.9) \ .time(datetime.utcnow(), WritePrecision.MS) with client.write_api(write_options=SYNCHRONOUS) as write_api: write_api.write(bucket=bucket, record=p) 
For more information, please check out the documentation.

Related resources

Write Millions of Points From CSV to InfluxDB with the 2.0 Python Client

In the benchmark, we compare the query times for data from the Billion Taxi Rides Dataset against several databases.

How to Control Crowds with Python, OpenCV and InfluxDB

Integrating OpenCV with InfluxDB to count the times it detects a face.

Start with Python and InfluxDB

This article examined a simple use case of a TSDB to store stock values to forecast.

The most powerful time series
database as a service

Developer Education

Training for time series app developers.