def register_admin_info(self, password): mysqlhelper = MysqlHelper(self.ip, self.port, self.dbname, self.dbuser, self.dbpassword) sql = "insert into administrator (username,password) value ('%s','%s')" % ( self.username, password) mysqlhelper.insert(sql) mysqlhelper.close()
def insert_mailbox_info(self, new_da_ip, **dict_mailbox_info): mysql_helper = MysqlHelper(new_da_ip, self.port, self.db_name, self.db_user, self.db_password) ls = [(k, v) for k, v in dict_mailbox_info.items() if v is not None] keys = ','.join([i[0] for i in ls]) values = ','.join(repr(i[1]) for i in ls) sql = "insert into mailbox (" + keys + ") values (" + values + ")" mysql_helper.insert(sql) mysql_helper.close()