Python Forum

Full Version: python mongo
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
Hi

Iam a beginner in python coding. I have a requirement to get the count from one column which is of Object type from mongodb. Below is the code which i have tried getting the value as 0.Could you please help.

from pymongo import MongoClient
from pprint import pprint
conn = MongoClient("xx.xx.xx.xx:27017")
with conn:
        db=conn.travel.Datatable
        propertyCount=db.find({"metadata.status" : "VALID"}).count()
        pprint(propertyCount)
When running the query in robomongo the result is as follows.
db.getCollection('Datatable').find({"metaData.status" : "VALID"}).count()
342045
(Oct-28-2020, 06:25 PM)beginner2020 Wrote: [ -> ]Hi

Iam a beginner in python coding. I have a requirement to get the count from one column which is of Object type from mongodb. Below is the code which i have tried getting the value as 0.Could you please help.

from pymongo import MongoClient
from pprint import pprint
conn = MongoClient("xx.xx.xx.xx:27017")
with conn:
        db=conn.travel.Datatable
        propertyCount=db.find({"metadata.status" : "VALID"}).count()
        pprint(propertyCount)
When running the query in robomongo the result is as follows.
db.getCollection('Datatable').find({"metaData.status" : "VALID"}).count()
342045

Could anybody please help
Hello,
Perhaps you should contact the maintainers of pymongo, they will probably get you an answer more quickly.
You can get their email addresses here: https://pypi.org/project/pymongo/