pymongo

MongoDB Atlas ServerSelectionTimeoutError: SSL handshake failed

MongoDB Atlas ServerSelectionTimeoutError: SSL handshake failed Question: I’m having a hard time fetching some data from my mongodb database using pymongo driver. I keep getting the following error: pymongo.errors.ServerSelectionTimeoutError: SSL handshake failed: ac-mtxrap4-shard-00-01.vfg8vpd.mongodb.net:27017: [SSL: TLSV1_ALERT_INTERNAL_ERROR] tlsv1 alert internal error (_ssl.c:1007),SSL handshake failed: ac-mtxrap4-shard-00-00.vfg8vpd.mongodb.net:27017: [SSL: TLSV1_ALERT_INTERNAL_ERROR] tlsv1 alert internal error (_ssl.c:1007),SSL handshake failed: ac-mtxrap4-shard-00-02.vfg8vpd.mongodb.net:27017: [SSL: TLSV1_ALERT_INTERNAL_ERROR] …

Total answers: 1

PyMongo save List of dict in subfield with own ObjectId for every dict entry

PyMongo save List of dict in subfield with own ObjectId for every dict entry Question: I’m creating a list of Objects in my script, and want so save/update them in a subfield of an mongo db document. My Objects looks like this: class IndividualRating: def __init__(self, place=0, player="", team="", games="", legs=""): self.place = place self.player …

Total answers: 1

Pymongo usage with vpn

Pymongo usage with vpn Question: I am kinda new to pymongo. Is there any possible way to connect to mongodb with the usage of the VPN, if I have server address, login and password of the vpn server? I have googled, but didn’t find anything useful. Asked By: Mikhail Zhokhov || Source Answers: Sure, here …

Total answers: 1

Update a specific array element if it fulfils at least one of several conditions

Update a specific array element if it fulfils at least one of several conditions Question: I am trying to understand (and fix) a code that is not mine, which uses PyMongo. We want to look for the document with _id==_id that has, inside its list comments, a comment with id==comment_id or id==PyObjectId(comment_id). To that comment …

Total answers: 1

How can I retrieve relative document in MongoDB?

How can I retrieve relative document in MongoDB? Question: I’m using Flask with Jinja2 template engine and MongoDB via pymongo. This are my documents from two collections (phone and factory): phone = db.get_collection("phone") { "_id": ObjectId("63d8d39206c9f93e68d27206"), "brand": "Apple", "model": "iPhone XR", "year": NumberInt("2016"), "image": "https://apple-mania.com.ua/media/catalog/product/cache/e026f651b05122a6916299262b60c47d/a/p/apple-iphone-xr-yellow_1.png", "CPU": { "manufacturer": "A12 Bionic", "cores": NumberInt("10") }, "misc": [ …

Total answers: 1

Optimising a basic group_by aggregation

Optimising a basic group_by aggregation Question: It’s possible that I’m just wildly naive but I would have thought that this aggregation would be quicker considering it’s somewhat simple – no complex joins of any kind and all the data is in a single simple table. It’s also likely that the answer to this question is …

Total answers: 1

Copy files from gridfs to another gridfs database

Copy files from gridfs to another gridfs database Question: I am searching for a way to copy files in gridfs. The idea is to keep all additional and metadata of the file, like the same "_id" etc. The use case is to setup a testing database with fraction of files in gridfs and maintaining the …

Total answers: 1

Unable to import module 'lambda_function': No module named 'pymongo'

Unable to import module 'lambda_function': No module named 'pymongo' Question: I have followed this guide last year to build my AWS python archive and it was working. Today i have automated my code deployment and it was not working (i am using shutil.make_archive("package", ‘zip’, root_dir=path, base_dir="package/", verbose=True) instead of the zip -r package.zip package/ command …

Total answers: 2

How to efficiently use PyMongo cursor

How to efficiently use PyMongo cursor Question: Please propose ways to access data returned from collections.find() in an efficient manner. Is a for iteration the recommended way? How do I keep the character of a cursor being an Iterable? Thx Asked By: Martin Senne || Source Answers: Briefly: A cursor implements methods of Iterable and …

Total answers: 1

Accessing PyMongo UpdateOne operation properties

Accessing PyMongo UpdateOne operation properties Question: If I am receiving a list of prepared PyMongo UpdateOne operations (e.g. below)… print(type(to_load[0])) > <class ‘pymongo.operations.UpdateOne’> print(to_load[0]) > UpdateOne({‘id’: XXX}, {‘$set’: {‘name’: ‘YYY’}}, True, None, None, None) …is it possible to then extract information from these? For instance, if I want to get a list of all of …

Total answers: 1