from pymongo import MongoClient from bson import ObjectId def bid_score(): # db = MongoClient('192.168.3.167', 27080, unicode_decode_error_handler="ignore").jyqyfw_historyData2023_1 # coll_user = db["20230921Ssk_endo"] db = MongoClient('192.168.3.206', 27080, unicode_decode_error_handler="ignore").data_quality coll_user = db["bidding_20231122"] count=0 score=100 for item in coll_user.find({"_id":ObjectId("655ec5319aed6eb2ffa5d77f")}): # for item in coll_user.find().sort("_id",1): if item.get('title_qa'): score-=10 if item.get('projectname_qa'): score-=10 if item.get('area_qa'): score-=10 if item.get('projectcode_qa'): score-=10 # if item['bidopentime_qa']: # score-=10 if item.get('buyer_qa'): score-=10 if item.get('winner_qa'): score-=10 if item.get('budget_qa'): score-=10 if item.get('bidamount_qa'): score-=10 if item.get("multipackage_qa"): score -= 10 print(score) coll_user.update_one({"_id": item["_id"]}, {"$set": {"score": score}}) score = 100 bid_score()