def update_fingerprint_index(db, index, limit=1000):
    with closing(index.connect()) as index:
        max_id = int(index.get_attribute('max_document_id') or '0')
        query = sql.select([
            schema.fingerprint.c.id,
            sql.func.acoustid_extract_query(schema.fingerprint.c.fingerprint),
        ]).where(schema.fingerprint.c.id > max_id).\
            order_by(schema.fingerprint.c.id).limit(limit)
        in_transaction = False
        for id, fingerprint in db.execute(query):
            if not in_transaction:
                index.begin()
                in_transaction = True
            logger.debug("Adding fingerprint %s to index %s", id, index)
            index.insert(id, fingerprint)
        if in_transaction:
            index.commit()
dataset/ETHPy150Open lalinsky/acoustid-server/acoustid/data/fingerprint.py/update_fingerprint_index/original