@@ -440,7 +440,8 @@ def write_points(self,
440
440
retention_policy = None ,
441
441
tags = None ,
442
442
batch_size = None ,
443
- protocol = 'json'
443
+ protocol = 'json' ,
444
+ consistency = None
444
445
):
445
446
"""Write to multiple time series names.
446
447
@@ -468,6 +469,8 @@ def write_points(self,
468
469
:type batch_size: int
469
470
:param protocol: Protocol for writing data. Either 'line' or 'json'.
470
471
:type protocol: str
472
+ :param consistency: Consistency for the points. One of {'any','one','quorum','all'}.
473
+ :type consistency: str
471
474
:returns: True, if the operation is successful
472
475
:rtype: bool
473
476
@@ -480,14 +483,14 @@ def write_points(self,
480
483
time_precision = time_precision ,
481
484
database = database ,
482
485
retention_policy = retention_policy ,
483
- tags = tags , protocol = protocol )
486
+ tags = tags , protocol = protocol , consistency = consistency )
484
487
return True
485
488
486
489
return self ._write_points (points = points ,
487
490
time_precision = time_precision ,
488
491
database = database ,
489
492
retention_policy = retention_policy ,
490
- tags = tags , protocol = protocol )
493
+ tags = tags , protocol = protocol , consistency = consistency )
491
494
492
495
def ping (self ):
493
496
"""Check connectivity to InfluxDB.
@@ -513,12 +516,16 @@ def _write_points(self,
513
516
database ,
514
517
retention_policy ,
515
518
tags ,
516
- protocol = 'json' ):
519
+ protocol = 'json' ,
520
+ consistency = None ):
517
521
if time_precision not in ['n' , 'u' , 'ms' , 's' , 'm' , 'h' , None ]:
518
522
raise ValueError (
519
523
"Invalid time precision is given. "
520
524
"(use 'n', 'u', 'ms', 's', 'm' or 'h')" )
521
525
526
+ if consistency not in ['any' , 'one' , 'quorum' , 'all' , None ]:
527
+ raise ValueError ('Invalid consistency: {}' .format (consistency ))
528
+
522
529
if protocol == 'json' :
523
530
data = {
524
531
'points' : points
@@ -533,6 +540,9 @@ def _write_points(self,
533
540
'db' : database or self ._database
534
541
}
535
542
543
+ if consistency is not None :
544
+ params ['consistency' ] = consistency
545
+
536
546
if time_precision is not None :
537
547
params ['precision' ] = time_precision
538
548
0 commit comments