def add_wishlist_items_to_db(wishlist_items): for i in wishlist_items: logger.info('Checking to see if {0} is in our db already'.format(i['ASIN'])) # check to see if we already have it, if not, add it to the database item_to_add = Item.query.filter_by(ASIN=i['ASIN']).filter(Item.live_data==False).first() if item_to_add is None: logger.info(' Don''t have it, adding now') item_to_add = Item(ASIN=i['ASIN']) item_to_add.is_on_wishlist = True db.session.add(item_to_add) db.session.commit() else: logger.info(' Yep, we had it')