airflow.providers.influxdb.hooks.influxdb
¶
This module allows to connect to a InfluxDB database.
Module Contents¶
-
class
airflow.providers.influxdb.hooks.influxdb.
InfluxDBHook
(conn_id: str = 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 (str) – Reference to Influxdb connection id.
-
get_uri
(self, conn: Connection)[source]¶ Function to add additional parameters to the URI based on SSL or other InfluxDB host requirements
-
get_conn
(self)[source]¶ Function that initiates a new InfluxDB connection with token and organization name
-
query
(self, query)[source]¶ Function to to run the query. Note: The bucket name should be included in the query
- Parameters
query – InfluxDB query
- Returns
List
-
query_to_df
(self, query)[source]¶ Function to 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
-
write
(self, bucket_name, point_name, tag_name, tag_value, field_name, field_value, synchronous=False)[source]¶ Writes a Point to the bucket specified. Example: Point(“my_measurement”).tag(“location”, “Prague”).field(“temperature”, 25.3)