def upsert_records(conn, records, upsert_statement):
    """Upsert records."""

    with conn:
        with conn.cursor() as cursor:
            for record in records:
                cursor.execute(upsert_statement, record)