@@ -472,7 +472,8 @@ def write_points(self,
472
472
retention_policy = None ,
473
473
tags = None ,
474
474
batch_size = None ,
475
- protocol = 'json'
475
+ protocol = 'json' ,
476
+ consistency = None
476
477
):
477
478
"""Write to multiple time series names.
478
479
@@ -500,6 +501,9 @@ def write_points(self,
500
501
:type batch_size: int
501
502
:param protocol: Protocol for writing data. Either 'line' or 'json'.
502
503
:type protocol: str
504
+ :param consistency: Consistency for the points.
505
+ One of {'any','one','quorum','all'}.
506
+ :type consistency: str
503
507
:returns: True, if the operation is successful
504
508
:rtype: bool
505
509
@@ -512,14 +516,16 @@ def write_points(self,
512
516
time_precision = time_precision ,
513
517
database = database ,
514
518
retention_policy = retention_policy ,
515
- tags = tags , protocol = protocol )
519
+ tags = tags , protocol = protocol ,
520
+ consistency = consistency )
516
521
return True
517
522
518
523
return self ._write_points (points = points ,
519
524
time_precision = time_precision ,
520
525
database = database ,
521
526
retention_policy = retention_policy ,
522
- tags = tags , protocol = protocol )
527
+ tags = tags , protocol = protocol ,
528
+ consistency = consistency )
523
529
524
530
def ping (self ):
525
531
"""Check connectivity to InfluxDB.
@@ -545,12 +551,16 @@ def _write_points(self,
545
551
database ,
546
552
retention_policy ,
547
553
tags ,
548
- protocol = 'json' ):
554
+ protocol = 'json' ,
555
+ consistency = None ):
549
556
if time_precision not in ['n' , 'u' , 'ms' , 's' , 'm' , 'h' , None ]:
550
557
raise ValueError (
551
558
"Invalid time precision is given. "
552
559
"(use 'n', 'u', 'ms', 's', 'm' or 'h')" )
553
560
561
+ if consistency not in ['any' , 'one' , 'quorum' , 'all' , None ]:
562
+ raise ValueError ('Invalid consistency: {}' .format (consistency ))
563
+
554
564
if protocol == 'json' :
555
565
data = {
556
566
'points' : points
@@ -565,6 +575,9 @@ def _write_points(self,
565
575
'db' : database or self ._database
566
576
}
567
577
578
+ if consistency is not None :
579
+ params ['consistency' ] = consistency
580
+
568
581
if time_precision is not None :
569
582
params ['precision' ] = time_precision
570
583
0 commit comments