Esempio n. 1
0
    def delete_series(self, database=None, measurement=None, tags=None):
        """Delete series from a database.

        Series can be filtered by measurement and tags.

        :param database: the database from which the series should be
            deleted, defaults to client's current database
        :type database: str
        :param measurement: Delete all series from a measurement
        :type measurement: str
        :param tags: Delete all series that match given tags
        :type tags: dict
        """
        database = database or self._database
        query_str = 'DROP SERIES'
        if measurement:
            query_str += ' FROM {0}'.format(quote_ident(measurement))

        if tags:
            tag_eq_list = [
                "{0}={1}".format(quote_ident(k), quote_literal(v))
                for k, v in tags.items()
            ]
            query_str += ' WHERE ' + ' AND '.join(tag_eq_list)
        self.query(query_str, database=database)
Esempio n. 2
0
    def set_user_password(self, username, password):
        """Change the password of an existing user.

        :param username: the username who's password is being changed
        :type username: str
        :param password: the new password for the user
        :type password: str
        """
        text = "SET PASSWORD FOR {0} = {1}".format(
            quote_ident(username), quote_literal(password))
        self.query(text)
Esempio n. 3
0
    def set_user_password(self, username, password):
        """Change the password of an existing user.

        :param username: the username who's password is being changed
        :type username: str
        :param password: the new password for the user
        :type password: str
        """
        text = "SET PASSWORD FOR {0} = {1}".format(quote_ident(username),
                                                   quote_literal(password))
        self.query(text)
Esempio n. 4
0
    def create_user(self, username, password, admin=False):
        """Create a new user in InfluxDB.

        :param username: the new username to create
        :type username: str
        :param password: the password for the new user
        :type password: str
        :param admin: whether the user should have cluster administration
            privileges or not
        :type admin: boolean
        """
        text = "CREATE USER {0} WITH PASSWORD {1}".format(
            quote_ident(username), quote_literal(password))
        if admin:
            text += ' WITH ALL PRIVILEGES'
        self.query(text)
Esempio n. 5
0
    def create_user(self, username, password, admin=False):
        """Create a new user in InfluxDB

        :param username: the new username to create
        :type username: str
        :param password: the password for the new user
        :type password: str
        :param admin: whether the user should have cluster administration
            privileges or not
        :type admin: boolean
        """
        text = "CREATE USER {0} WITH PASSWORD {1}".format(
            quote_ident(username), quote_literal(password))
        if admin:
            text += ' WITH ALL PRIVILEGES'
        self.query(text)
Esempio n. 6
0
    def delete_series(self, database=None, measurement=None, tags=None):
        """Delete series from a database. Series can be filtered by
        measurement and tags.

        :param database: the database from which the series should be
            deleted, defaults to client's current database
        :type database: str
        :param measurement: Delete all series from a measurement
        :type id: str
        :param tags: Delete all series that match given tags
        :type id: dict
        """
        database = database or self._database
        query_str = 'DROP SERIES'
        if measurement:
            query_str += ' FROM {0}'.format(quote_ident(measurement))

        if tags:
            tag_eq_list = ["{0}={1}".format(quote_ident(k), quote_literal(v))
                           for k, v in tags.items()]
            query_str += ' WHERE ' + ' AND '.join(tag_eq_list)
        self.query(query_str, database=database)
Esempio n. 7
0
 def test_quote_literal(self):
     self.assertEqual(
         line_protocol.quote_literal(r"""\foo ' bar " Örf"""),
         r"""'\\foo \' bar " Örf'"""
     )
 def test_quote_literal(self):
     self.assertEqual(line_protocol.quote_literal(r"""\foo ' bar " Örf"""),
                      r"""'\\foo \' bar " Örf'""")
 def test_quote_literal(self):
     """Test quote literal in TestLineProtocol object."""
     self.assertEqual(line_protocol.quote_literal(r"""\foo ' bar " Örf"""),
                      r"""'\\foo \' bar " Örf'""")
 def test_quote_literal(self):
     """Test quote literal in TestLineProtocol object."""
     self.assertEqual(
         line_protocol.quote_literal(r"""\foo ' bar " Örf"""),
         r"""'\\foo \' bar " Örf'"""
     )