0
   TPID=[318,205,2624,2635]
   Tid= len(TPID)
    try:
        mclient = MongoClient(host="tgl-mongodb22.rctanalytics.com", port=27017)
        Db = mclient['sitereft4']
        Db.authenticate('st_sitereference', 'rlQ2YnPKNlS0')
        coll = Db['shopper_journey_sitedata']
        for i in range(Tid):
            data = coll.find({"third_party_site_id":318})
            for datas in data:
                None
        print(datas["st_site_id"])

In place of 318 i need to pass the variable "Tid" so that it should run for all values. how to do it ? i tried below one it didn't worked: data = coll.find({"third_party_site_id":Tid[i]})

1
  • I tried that too, its not working. Commented Aug 3, 2020 at 8:32

1 Answer 1

1

If your goal is to find each site id in TPID=[318,205,2624,2635]

Structure the for loop logic as:

for i in TPID:
    data = coll.find({"third_party_site_id":i})
    print(data)
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.