Search code examples
pythonpython-asyncioinfluxdbaioinflux

How to add different tags to all elements of a list of user-defined dataclasses, when attempting to insert the list in influxdb using one call


I'm trying to insert an whole list of user-defined dataclasses in my influxdb server, and provide different tags to each, while also using a single write call. I'm using aioinflux.

Is this possible? So far, I've been looking at the aioinflux.InfluxDBClient's write function.

I see that there it has a tag_columns argument, but the docs indicate that it can only be used in tandem with dataframes. Then there is the extra_tags argument, but since I want to write a list of dataclasses using a single write call, the method seems rather useless in this case.

Any ideas?


Solution

  • I was waylaid by how the write function is structured. Basically, it seems that its extra_tags argument has no effect on user-defined dataclass objects.

    After doing a little bit of random searching I found out this table which suggests that one can add tags to each datapoint by making the tags part of the dataclass. This way, one can insert an Iterable of dataclasses and make sure that they have tags.