def load_aead(self, public_id):
        """ Loads AEAD from the specified database. """
        connection = self.engine.connect()
        trans = connection.begin()

        try:
            s = sqlalchemy.select([self.aead_table]).where(
                (self.aead_table.c.public_id == public_id)
                & self.aead_table.c.keyhandle.in_([kh[1] for kh in self.key_handles]))
            result = connection.execute(s)

            for row in result:
                kh_int = row['keyhandle']
                aead = pyhsm.aead_cmd.YHSM_GeneratedAEAD(None, kh_int, '')
                aead.data = row['aead']
                aead.nonce = row['nonce']
            return aead
        except Exception as e:
            trans.rollback()
            raise Exception("No AEAD in DB for public_id %s (%s)" % (public_id, str(e)))
        finally:
            connection.close()
Loads AEAD from the specified database.