|
@@ -115,3 +115,26 @@ class InfluxdbHandler:
|
|
|
'\' tz(\'Europe/Berlin\');'
|
|
|
|
|
|
return self.query_to_dataframe(query)
|
|
|
+
|
|
|
+ def insert_dataframe(self, dataframe: pd.DataFrame,
|
|
|
+ batch_size: int = 10000,
|
|
|
+ time_precision: str = 'u'):
|
|
|
+ """
|
|
|
+ :param dataframe: DESCRIPTION
|
|
|
+ :type dataframe: pd.DataFrame
|
|
|
+ :return: DESCRIPTION
|
|
|
+ :rtype: TYPE
|
|
|
+
|
|
|
+ """
|
|
|
+ for column in dataframe.columns:
|
|
|
+ try:
|
|
|
+ self.client.write_points(
|
|
|
+ dataframe=dataframe[column].to_frame(),
|
|
|
+ measurement=column,
|
|
|
+ protocol='line',
|
|
|
+ batch_size=batch_size,
|
|
|
+ time_precision=time_precision)
|
|
|
+
|
|
|
+ except Exception as error:
|
|
|
+ self._logger.loger_and_raise_error(
|
|
|
+ ('Could not insert data, Error: {}'.format(error)))
|