Questions tagged [pymongo-3.x]

Version 3 of [pymongo]

Version 3 of the official Python driver for MongoDB.

PyMongo 3 is not backward compatible with PyMongo 2:

PyMongo 3.0 brings a large number of API changes. Be sure to read the changes listed below before upgrading from PyMongo 2.x

Warning: PyMongo no longer supports Python 2.4, 2.5, or 3.1. If you must use PyMongo with these versions of Python the 2.x branch of PyMongo will be minimally supported for some time.

See the full changelog for more information.

If you're not sure what version of PyMongo you're running, consider using the generic tag.

324 questions
0
votes
0 answers

The order of dictionary formed in $project of aggregate pipeline, changes while fetching in pymongo

I am facing issue in lookup in MongoDB query which is stored and called using pymongo3.3. There is an ID column in lookup collection which is dictionary. I am creating this LookupID column in project, but the project is changing the order of…
JJ_R
  • 25
  • 1
  • 1
  • 7
0
votes
0 answers

TypeError: 'collection' object is not callable.' when trying to upload several files to mlab collection

I am trying to iterate through a list of files in a folder. As iterate through them I would like to add each and everyone of them. however, I receive TypeError: 'collection' object is not callable. ive tried changing the directories and how I access…
0
votes
1 answer

Only get one data from collections?

Im have some data from my collection at mongoDb i want to see all data from specified collection let say i've simple code like this from pymongo import MongoClient url = 'my url' client = MongoClient(url, ssl=True, retryWrites=True) class…
alnyz
  • 91
  • 1
  • 1
  • 9
0
votes
0 answers

Reading image data from MongoDB with pymongo fails

I have an image saved in MongoDB in the table with following method: @staticmethod def upload_member_image(member_id, raw_image): Database.insert("files", {"_id": uuid.uuid4().hex, "member_id": member_id, …
smoczyna
  • 489
  • 6
  • 18
0
votes
1 answer

Plotly-Dash and Mongodb DuplicateKeyError

Within a plotly-dash application, I am entering some user-specified data into a mongoDB database. The Issue: The first entry of the information is successful, however, any consecutive entries are not and a pymongo.errors.DuplicateKeyError is…
Avaricious_vulture
  • 1,114
  • 8
  • 10
0
votes
1 answer

Can we print out only the values of the documents that are present in the collection using python?

output: {u'country': u'USA', u'age': 35.0, u'_id': ObjectId('5c481307c45c2d388de3b4ba'), u'id': 11.0, u'name': u'Sachin'} {u'country': u'India', u'age': 33.0, u'_id': ObjectId('5c481307c45c2d388de3b4bb'), u'id': 12.0, u'name': u'Rahul'} {u'country':…
0
votes
1 answer

flask-pymongo: I put mongo in a separate python file, and it became NoneType

I have three files: params.py like this: from flask_pymongo import PyMongo mongo = PyMongo() server.py like this: from params import mongo mongo.init_app(app) A function regarding a post in a blueprint in views.py like this: from params import…
0
votes
0 answers

difference between mongodb shell find with regex and same one with Python

Data: I have 3 mongodb documents, two of them contain '04'. It is working fine with mongo shell, but not when I script it with Python... Let's see my documents and the regex find results as expected: MongoDB shell version: 3.2.11 connecting to:…
fdav
  • 1
  • 3
0
votes
1 answer

PyMongo: how to query a series and find the closest match

This is a simplified example of how my data is stored in MongoDB of a single athlete: { "_id" : ObjectId('5bd6eab25f74b70e5abb3326'), "Result" : 12, "Race" : [0.170, 4.234, 9.170] "Painscore" : 68, } Now when this athlete has…
Nout
  • 33
  • 7
0
votes
1 answer

Django function to return the result of MongoDB aggregate pipeline

I would really appreciate if someone can help me with this. I need Django (Python) function to inject some parameters into a pipeline script, pass it to MongoDB Atlas and receive the result in a cursor. from bson import ObjectId import pymongo conn…
0
votes
1 answer

convert CSV file to nested JSON and insert in to mongodb using python

I have a CSV file named data.csv. I want to convert this flat CSV file in to nested JSON and insert it in to mongodb using python.Below is the code which i have used to convert CSV to nested JSON, but i am not able to insert it in to mongodb. it…
swetha reddy
  • 201
  • 5
  • 19
0
votes
1 answer

MongoDB query with nested structure

How can I query (in MongoDB) this nested json structure in order to get only the nested object which has the "position" value equal to "currentPosition" value? { "JobId": "123" "currentPosition" : NumberInt(18), "details" : [ …
Parth Pandya
  • 39
  • 1
  • 12
0
votes
2 answers

Python - ImportError: No module named 'pymongo' despite pip says "requirement already satisfied" [Windows]

As the title clearly describes, despite I have successfully installed PyMongo thru the suggested way (executing the command python -m pip install pymongo), getting an error like ImportError: No module named 'pymongo' when I try to execute a Python…
talha06
  • 6,206
  • 21
  • 92
  • 147
0
votes
0 answers

pymongo insert_one document structure is lost

I have a Python3 application which inserts movie information into a mongodb back-end (MongoDB Compass), and a separate nodejs application which returns it. this was working fine, however i cleared the DB out and re-ran the application, now when I…
JONAS402
  • 591
  • 1
  • 9
  • 18
0
votes
1 answer

How to get a database and collection from MongoDB ClientSession

I am trying to create a connection to a database - collection using a ClientSession in pymongo 3.7.1. From the example provided by the doc here : https://docs.mongodb.com/manual/core/transactions/, it seems possible to get a connection to a database…
Alexis Rosuel
  • 563
  • 1
  • 5
  • 12