PyMongo is the official Python driver for MongoDB created and maintained by MongoDB, Inc. Please mention the version of PyMongo you're using.
PyMongo is the official Python driver for MongoDB created and maintained by MongoDB, Inc.
Note: Since PyMongo 3 is not backward compatible with PyMongo 2 (refer to the changelog for details), you should specify the version you're using in the body of your question.
I tried setting connectTimeoutMS and socketTimeoutMS to a low value but it still takes about 20 seconds before my script times out. Am I not using the options correctly? I want the script to exit after 5 seconds.
def init_mongo():
…
I know this is a fairly common problem. I'm writing a small Flask app and I'm trying to feed some queries back to the view.
I've connected to my local MongoDB setup, and made a successful query - but I can't generate a json object with it.
The…
I'm currently creating a website in python (pyramid) which requires users to sign up and log in. The system allows for users to choose a username which can be a mixture of capital letters, lowercase letters, and numbers.
The problem arises when…
I'm running into the aggregation result exceeds maximum document size (16MB) error with mongodb aggregation using pymongo.
I was able to overcome it at first using the limit() option. However, at some point I got the
Exceeded memory limit for…
I'm having trouble getting a simple Hello World app to work using Flask, MongoDB, and Python. The app is bombing when trying to import from the bson module. All modules were installed successfully via pip and I'm running in a virtualenv, so I'm not…
How to insert datetime string like this "2017-10-13T10:53:53.000Z" into mongo db as ISODate?
I get a string in mongodb when I insert:
datetime.strptime("2017-10-13T10:53:53.000Z", "%Y-%m-%dT%H:%M:%S.000Z")
How can i create index in pymongo with 2 fields, to be unique together?
I have this code:
self.db[self.mongo_collection].create_index("url", unique=True)
but i need to be unique with url and category.
I'm trying to get the timestamp from an ObjectID, but Mongo keeps giving me this error. Am I missing an import? What's the best way to convert the timestamp to a standard date format?
video['date'] = video['_id'].getTimeStamp()
I asked this same question on the mongodb-user list: http://groups.google.com/group/mongodb-user/browse_thread/thread/b3470d6a867cd24
I was hoping someone on this forum might have some insight...
I've run a simple experiment comparing the…
I use scarpy to crawl data and save it to cloud hosting mLab successfully with MongoDB.
My collection name is recently and data's count is 5.
I want to crawl data again and update my collection recently, so i try to drop the collection and then…
I seem to be struggling to find the right way of deleting a document. I.e. should I be using remove() or delete_one() for example and also what is the canonical method of deleting by id, which is a string.
I.e. should I be using the…
I'm developing a python project, in the requirements file I have three different types of PyMongo
Flask-PyMongo==0.3.1
pymongo==2.7
flask-mongoengine==0.7.1
How can I define which version I'm using?
I have the following functions:
# this is in a module called 'dbw_lib'
def dateTimeOuput(start_days_back, end_days_back):
start_delta = datetime.timedelta(days=start_days_back)
end_delta = datetime.timedelta(days=end_days_back)
…
I'm executing bulk write
bulk = new_packets.initialize_ordered_bulk_op()
bulk.insert(packet)
output = bulk.execute()
and getting an error that I interpret to mean that packet is not a dict. However, I do know that it is a dict. What could be the…