Peter Otten wrote: If you create indices for floors (and rooms)
cur.execute("""create unique index room_index on rooms (fid, number);""") cur.execute("""create unique index floor_index on floors (floor);""") the addition of missing rows can be simplified to missing = c2.execute("""select distinct floor from new_employees;""") cur.executemany("insert or ignore into floors (floor) values (?)", missing) etc. Peter -- http://mail.python.org/mailman/listinfo/python-list