airflow.providers.influxdb.hooks.influxdb

This module allows to connect to a InfluxDB database.

Module Contents

Classes

InfluxDBHook

Interact with InfluxDB.

class airflow.providers.influxdb.hooks.influxdb.InfluxDBHook(conn_id=default_conn_name, *args, **kwargs)[source]

Bases: airflow.hooks.base.BaseHook

Interact with InfluxDB.

Performs a connection to InfluxDB and retrieves client.

Parameters

influxdb_conn_id – Reference to Influxdb connection id.

conn_name_attr = 'influxdb_conn_id'[source]
default_conn_name = 'influxdb_default'[source]
conn_type = 'influxdb'[source]
hook_name = 'Influxdb'[source]
get_client(uri, token, org_name)[source]
get_uri(conn)[source]

Add additional parameters to the URI based on InfluxDB host requirements.

get_conn()[source]

Initiate a new InfluxDB connection with token and organization name.

query(query)[source]

Run the query.

Note: The bucket name should be included in the query.

Parameters

query – InfluxDB query

Returns

List

Return type

list[influxdb_client.client.flux_table.FluxTable]

query_to_df(query)[source]

Run the query and return a pandas dataframe.

Note: The bucket name should be included in the query.

Parameters

query – InfluxDB query

Returns

pd.DataFrame

Return type

pandas.DataFrame

write(bucket_name, point_name, tag_name, tag_value, field_name, field_value, synchronous=False)[source]

Write a Point to the bucket specified.

Example: Point("my_measurement").tag("location", "Prague").field("temperature", 25.3)

create_organization(name)[source]

Create a new organization.

delete_organization(org_id)[source]

Delete an organization by ID.

create_bucket(bucket_name, description, org_id, retention_rules=None)[source]

Create a bucket for an organization.

find_bucket_id_by_name(bucket_name)[source]

Get bucket ID by name.

delete_bucket(bucket_name)[source]

Delete bucket by name.

Was this entry helpful?