Python Forum
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
python mongo
#1
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
Reply
#2
(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
Reply
#3
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/
Reply


Possibly Related Threads…
Thread Author Replies Views Last Post
  Convert a mongo db scrip to python equivalent Herath 1 2,163 Aug-20-2019, 02:28 PM
Last Post: fishhook
  Boto 3 and Mongo DB zatlas1 2 2,907 May-23-2019, 07:32 PM
Last Post: zatlas1

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020