def upgrade(): cryptoKey = Config().getPrivateKey() connection = op.get_bind() with connection.begin() as trans: for host in connection.execute(hostsHelper.select().where( hostsHelper.c.password.isnot(None))): try: passwordToUpdate = cryptoKey.encrypt(host.password) connection.execute(hostsHelper.update().where( hostsHelper.c.id == host.id).values( password=passwordToUpdate)) except Exception as e: logger.error(u"Error when trying to update host '{}'.".format( host.name)) raise e
def upgrade(): cryptoKey = Config().getPrivateKey() connection = op.get_bind() with connection.begin() as trans: for host in connection.execute(hostsHelper.select().where(hostsHelper.c.password.isnot(None))): try: passwordToUpdate = cryptoKey.encrypt(host.password) connection.execute( hostsHelper.update().where( hostsHelper.c.id == host.id ).values(password=passwordToUpdate) ) except Exception as e: logger.error(u"Error when trying to update host '{}'.".format(host.name)) raise e