diff --git a/influxdb/client.py b/influxdb/client.py index c3687934..c0721237 100644 --- a/influxdb/client.py +++ b/influxdb/client.py @@ -62,7 +62,37 @@ def switch_user(self, username, password): def write_points(self, *args, **kwargs): """ Write to multiple time series names - """ + + Parameters + ---------- + batch_size : Optional. Int value to write the points in batches instead + of all at one time. + Useful for when doing data dumps from one database to another or + when doing a massive write operation + """ + + def list_chunks(l, n): + """ Yield successive n-sized chunks from l. + """ + for i in xrange(0, len(l), n): + yield l[i:i+n] + + batch_size = kwargs.get('batch_size') + if batch_size: + for data in kwargs.get('data'): + name = data.get('name') + columns = data.get('columns') + point_list = data.get('points') + total_batches = len(point_list) * 1.0/batch_size + for batch in list_chunks(point_list, batch_size): + data = [{"points": batch, + "name": name, + "columns": columns}] + time_precision = kwargs.get('time_precision', 's') + self.write_points_with_precision(data=data, + time_precision=time_precision) + return True + return self.write_points_with_precision(*args, **kwargs) def write_points_with_precision(self, data, time_precision='s'): pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy