Example #1
0
    def grantPermissions(self, dbname, username):
        host = self.okHost(username) or "%.sabren.com"

        sql =\
            """
            GRANT SELECT, INSERT, UPDATE, DELETE,
                  CREATE, CREATE TEMPORARY TABLES,
                  DROP, INDEX, ALTER, LOCK TABLES
            ON %s.*
            TO %s@'%s'
            """ % (self.sanitize(dbname),
                   self.sanitize(username), self.sanitize(host))

        if host:
            password = '******'
        else:
            password = handy.randpass()
            sql += "IDENTIFIED BY '%s'" % password

        self.execute(sql)

        # and this is so the db table ONLY has '%' in it
        self.execute("update db set host='%'")
        return password
Example #2
0
    def grantPermissions(self, dbname, username):
        host = self.okHost(username) or "%.sabren.com"
        
        sql =\
            """
            GRANT SELECT, INSERT, UPDATE, DELETE,
                  CREATE, CREATE TEMPORARY TABLES,
                  DROP, INDEX, ALTER, LOCK TABLES
            ON %s.*
            TO %s@'%s'
            """ % (self.sanitize(dbname),
                   self.sanitize(username), self.sanitize(host))
        
        if host:
            password = '******'
        else:
            password = handy.randpass()
            sql += "IDENTIFIED BY '%s'" % password

        self.execute(sql)

        # and this is so the db table ONLY has '%' in it
        self.execute("update db set host='%'")
        return password
Example #3
0
 def __init__(self, **args):
     super(Account, self).__init__(**args)
     if not self.password:
         self.password = randpass()