Python Forum
python mongo - Printable Version

+- Python Forum (https://python-forum.io)
+-- Forum: Python Coding (https://python-forum.io/forum-7.html)
+--- Forum: General Coding Help (https://python-forum.io/forum-8.html)
+--- Thread: python mongo (/thread-30622.html)



python mongo - beginner2020 - Oct-28-2020

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


RE: python mongo - beginner2020 - Oct-29-2020

(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


RE: python mongo - Larz60+ - Oct-29-2020

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/