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 Thumbnails


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 Thumbnails