1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39
| from sqlalchemy.dialects.mysql import insert
new_items = [] for item in item_lst: _item = dict( dt=datetime.now().strftime("%Y-%m-%d"), create_time=datetime.now().strftime("%Y-%m-%d %H:%M:%S"), item_id=item.get("item_id"), shop_id=item.get("shop_id"), comment_id=item.get("comment_id"), comment_content=item.get("comment_content"), comment_seller_name=item.get("comment_seller_name", None), comment_sku=item.get("comment_sku", None), comment_time=item.get("comment_time", None), sale_day=item.get("sale_day", None), ) new_items.append(_item) insert_stmt = ( insert(TMallGoodsCommentNew).values(new_items).prefix_with("IGNORE") ) session.execute(insert_stmt) session.commit()
record = DayInfoTable( dt=datetime.now(), device_id=device_id, collect_type=collect_type, req_success_count=0, req_fail_count=0, slide1_success_count=0, slide1_fail_count=0, slide2_success_count=0, slide2_fail_count=0, create_time=datetime.now(), ) db_session.add(record) db_session.commit()
|