def import_rent_list(self, user_id): c = self.mconn.cursor() c.execute("select w.add_date, w.position, i.upc, i.id from wishes w inner join items i on w.ref_item=i.id where w.ref_user=%s order by w.id", [user_id,]) for add_date, position, upc, id in c.fetchall(): item = self.get_item(upc) if not item: self.missing_items.add(id) continue rl = RentList( user_id = user_id, item = item, order = position, added = add_date ) rl.save()