Article 59PN6 python mongo

python mongo

by
nextStep
from LinuxQuestions.org on (#59PN6)
Hello Team,

I am struggling to get value from one column in robomongo using python.
The below query when executed in robomongo will give us the value as
7306

db.getCollection('finishedLocations').find({"metaData.status" : "VALID"}).count()

This value needed to be fetched using python program. Below is the code.

Code:

from pymongo import MongoClient
myclient = MongoClient("mongoclient:27017")
myDb = myclient["travel"]
mycollections = myDb["finishedLocations"]
x=mycollections.find({"metadata.status" : "VALID"})
print x.count()x prints as 0. I believe code is not reaching till the status field to get the value .
Any help is appreciated. The data type is attached herewith.
Attached Thumbnailsattachment.php?attachmentid=34432&stc=1& latest?d=yIl2AUoC8zA latest?i=ribfiqY7rKs:ect-qtfofpo:F7zBnMy latest?i=ribfiqY7rKs:ect-qtfofpo:V_sGLiP latest?d=qj6IDK7rITs latest?i=ribfiqY7rKs:ect-qtfofpo:gIN9vFwribfiqY7rKs
External Content
Source RSS or Atom Feed
Feed Location https://feeds.feedburner.com/linuxquestions/latest
Feed Title LinuxQuestions.org
Feed Link https://www.linuxquestions.org/questions/
Reply 0 comments