Create an ISODate with pyMongo

You just need to store an instance of datetime.datetime. Inserting from the python shell: >>> c.test.test.insert({‘date’: datetime.datetime.utcnow()}) ObjectId(‘4e8b388367d5bd2de0000000′) >>> c.test.test.find_one() {u’date’: datetime.datetime(2011, 10, 4, 16, 46, 59, 786000), u’_id’: ObjectId(‘4e8b388367d5bd2de0000000’)} Querying in the mongo shell: > db.test.findOne() { “_id” : ObjectId(“4e8b388367d5bd2de0000000”), “date” : ISODate(“2011-10-04T16:46:59.786Z”) }

How to limit mongo query in python

As specified in this question, indexed access will ignore the limit. And count() does not obey limit or skip by default as explained the manual. You can pass with_limit_and_skip=True to make count() work with limit. print db_data.count(with_limit_and_skip=True) Or you can iterate the cursor to see limit in effect. for data in db.myusers.find().limit(2): print data

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)