New York MongoDB User Group Message Board › I'm having problems with pymongo

I'm having problems with pymongo

Burton W.
user 13229537
New York, NY
Post #: 1
All -

I have a large collection (10's of millions of docs) that i am trying to query. When i run find with my query from the mongo shell, all is well. I get the expected count(millions) However, when i do it from pymongo, its totally wrong. I get back a significantly smaller count (thousands). I can't seem to find whats wrong or off here. Has anyone seen this problem? suggestions would be great. Thanks.

Python Shell
>>> csr = st.find({"created_at_datetime"­: {"$lte": datetime.datetime(2011, 8, 31, 0, 0),"$gte": datetime.datetime(2011, 8, 1, 0, 0)}})
>>> csr.count()
4828

Mongo Shell

> db.collection.find({'created_at_datetime­': {$lte: new Date(2011, 8, 31), $gte: new Date(2011, 8,1)}}).count()
3487579

python 2.7+
pymongo 2.0.1
MongoDB shell version: 2.0.0

Thanks.

-B
A former member
Post #: 1
I think that javascript dates use 0-based months, but python uses 1-based, so your queries are actually over different periods.

--Andy
Burton W.
user 13229537
New York, NY
Post #: 2
That was it! thanks a lot Andy!

-B
Powered by mvnForum

Our Sponsors

  • MongoDB

    MongoDB organizes the NY MongoDB User Group

  • O'Reilly

    Members save 40% off print and 50% off ebooks use discount code DSUG

People in this
Meetup are also in:

Sign up

Meetup members, Log in

By clicking "Sign up" or "Sign up using Facebook", you confirm that you accept our Terms of Service & Privacy Policy