Skip to content

Tag: pymongo

MongoDB/Python – Date in collection (to use for query)

I just started using mongoDB (Version 3.6.8) today, and I like it. I was reading that it should be possible to have a date object directly in the database, but I can’t get it to work. Also I was wondering if it is the best solution or if I should just store my dates as “Epoch millis” instead…

pymongo auth failed in python script

I have installed mongodb and enabled auth. and its working find. I can connect it from remote notebook using robomongo application: and We can connect from server shell locally using: Everything works fine, but when we try it using pymongo api. authentications failed. below is the python code: Tools used: Err…

How to run MongoDB commands with pymongo?

I need to see list of connections to MongodDB. I know how to do it in mongo console: Now I want to do the same using pymongo. I tried following and it didn’t work: After that I used db.command() in various combinations trying to pass “db.currentOp(true)” to it without success. How to do it p…

Removing _id element from Pymongo results

I’m attempting to create a web service using MongoDB and Flask (using the pymongo driver). A query to the database returns documents with the “_id” field included, of course. I don’t want to send this to the client, so how do I remove it? Here’s a Flask route: This returns: I tho…