def insert_variation(session, metadata, buffer):
    """
    Populate the variants table with each variant in the buffer.
    """
    if len(buffer) == 0: return
    tbl = metadata.tables['variants']

    cols = _get_cols(tbl)

    left = set(buffer[0].keys()) - set(cols)
    assert len(left) == 0, left
    left = set(buffer[0].keys()) - set(cols)
    assert len(left) == 0, left

    try:
        session.execute(tbl.insert(), buffer)
        session.commit()
    except:
        sys.stderr.write("insert error trying 1 at a time:\n")
        session.rollback()
        stmt = tbl.insert()
        with session.bind.begin() as trans:
            for b in buffer:
                trans.execute(stmt, b)
        raise
dataset/ETHPy150Open arq5x/gemini/gemini/database.py/insert_variation/swapped operands of `-`