@@ -485,15 +485,15 @@ def create_database(self, dbname):
485
485
:param dbname: the name of the database to create
486
486
:type dbname: str
487
487
"""
488
- self .query ("CREATE DATABASE \" %s \" " % dbname )
488
+ self .query ("CREATE DATABASE {0}" . format ( quote_ident ( dbname )) )
489
489
490
490
def drop_database (self , dbname ):
491
491
"""Drop a database from InfluxDB.
492
492
493
493
:param dbname: the name of the database to drop
494
494
:type dbname: str
495
495
"""
496
- self .query ("DROP DATABASE \" %s \" " % dbname )
496
+ self .query ("DROP DATABASE {0}" . format ( quote_ident ( dbname )) )
497
497
498
498
def create_retention_policy (self , name , duration , replication ,
499
499
database = None , default = False ):
@@ -517,9 +517,10 @@ def create_retention_policy(self, name, duration, replication,
517
517
:type default: bool
518
518
"""
519
519
query_string = \
520
- "CREATE RETENTION POLICY \" %s\" ON \" %s\" " \
521
- "DURATION %s REPLICATION %s" % \
522
- (name , database or self ._database , duration , replication )
520
+ "CREATE RETENTION POLICY {0} ON {1} " \
521
+ "DURATION {2} REPLICATION {3}" .format (
522
+ quote_ident (name ), quote_ident (database or self ._database ),
523
+ duration , replication )
523
524
524
525
if default is True :
525
526
query_string += " DEFAULT"
@@ -597,8 +598,15 @@ def get_list_retention_policies(self, database=None):
597
598
u'name': u'default',
598
599
u'replicaN': 1}]
599
600
"""
601
+
602
+ if not (database or self ._database ):
603
+ raise InfluxDBClientError (
604
+ "get_list_retention_policies() requires a database as a "
605
+ "parameter or the client to be using a database" )
606
+
600
607
rsp = self .query (
601
- "SHOW RETENTION POLICIES ON \" %s\" " % (database or self ._database )
608
+ "SHOW RETENTION POLICIES ON {0}" .format (
609
+ quote_ident (database or self ._database ))
602
610
)
603
611
return list (rsp .get_points ())
604
612
0 commit comments