def add_group(dn, entry, source): group = { 'cn' : entry['cn'][0], 'source' : source, } for dn in entry['member']: insert_group = dict(group, **{'member' : dn}) query = insert(GROUP_TABLE, insert_group) cursor.execute(query)
def add_person(dn, entry, source): person = {'dn' : dn} for attribute in entry: if attribute in person2table.keys(): # TODO: Fix; Unreadable as f**k. person[person2table[attribute]] = entry[attribute][0] person['source'] = source print person query = insert(PEOPLE_TABLE, person) cursor.execute(query)