I would like to create a table in InfluxDB and then write a pandas dataframe to it. Thus, I need to develop a function:
def write_df_to_influx(df: pd.DataFrame, client: InfluxDBClient, table_name: str)
The official documentation states that the intended way of writing entries in bulk is to use SeriesHelper
class. The documented use case seems to suggest that I need to create a class inside of a class, where I would explicitly specify the bulk_size, as well as the fields and tags. I do not really understand this design choice, but my only concern is how to use it in a generic manner to write my function.
Is it safe to create __init__
method for MySeriesHelper
, that would init the parent SeriesHelper
, and also use additional parameters to pass directly to the nested Meta
class? I’m not an expert in python OOP, and I am mildly afraid that the SeriesHelper
has some hidden rules that I need to follow.
class MySeriesHelper(SeriesHelper):
def __init__(*args, my_meta: dict = None, **kwargs):
super(MySeriesHelper, self).__init__(*args, **kwargs)
self.my_meta = my_meta
class Meta:
tags = self.my_meta['tags']
# More of the Meta class omitted