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
1 answer

How to search a key value in mongodb based on tag name in a deeply nested document?

db.props.aggregate([{"$match":{release:"1"}},{"$project":{'_id':0, 'SHK.0':{"$filter":{"input":'$SHK.0.host',"as":'fil', "cond":{$in:['$$fil.Tags',"cd"]}}}}}]) I used the above to query my dataset listed below :: { "_id" :…
0
votes
1 answer

How to Define and Use Variables in Pymongo Aggregation Script

I am trying to learn about mongodb aggregation. I've been able to get the commands to work for a single output. I am now working on a pymongo script to parse through a dirty collection and output sterilised data into a clean collection. I am stuck…
0
votes
1 answer

how to convert mongodb query to pymongo

I have a collection of mongodb, which contains "MoviesID, UserID, Rating", so this is to describe the how the users rate different movies, and a user can rate different movies, and certainly a movie can be rated by different users. Now I want to…
CPP
  • 91
  • 1
  • 12
0
votes
1 answer

mongodb how to maintain an unique array

I am using $push to appends a value to an array. connection.erp_datasets.erp_datasets.update_one({'erp_name': 'erp1'}, {'$push': {'data_set': 'database1'}}, upsert=True) The problem is whenever I run the…
daiyue
  • 7,196
  • 25
  • 82
  • 149
0
votes
1 answer

pymongo - how to append values to array?

I am trying to create a database if it is not there already in mongo, and then create a collection in the database; then insert/update a document (which contains two keys, called erp and dataset whose value is a list of strings) in the collection. I…
daiyue
  • 7,196
  • 25
  • 82
  • 149
0
votes
0 answers

Process every string in specific field of a Collection

I'm working with Python 3.6, Pymongo 3.3.0 and MongoDB version 2.6.12. I'm a total beginner both with Python and MongoDB, sorry if the answer seems to obvious. I am lacking a general concept of building some kind of data processing pipeline to…
oxymoron
  • 13
  • 4
0
votes
0 answers

Use index of object in MongoDB to return result

Below is a collection in mongodb. I need to return the bus_number given a start stop and an end stop. the constraint is that that the index of the end stop has to be greater than the index of the start stop. So, given start=226 & end=229 the…
0
votes
0 answers

BulkWriteError in pymongo when inserting documents

I am trying to get some dummy _id from mongodb, for that i have written the following snippet of code, but it is throwing BulkWriteError. def get_unique_ids(count): return db.insert_many([{}] * count).inserted_ids Exception: execute_command …
daemon24
  • 1,388
  • 1
  • 11
  • 23
0
votes
1 answer

PyMongo - UserNotFound: Could not find user authenticated@admin

I checked the permission on the /etc/mongod.conf: vagrant@trusty64:/vagrant/test$ sudo docker exec -it mongodb ls -l /etc/mongod.conf -rw-r--r-- 1 root root 472 Jun 22 00:09 /etc/mongod.conf Then, I checked it's corresponding…
0
votes
2 answers

'CommandCursor' object is not subscriptable

When i run this code ,i get an error 'CommandCursor' object is not subscriptable pymongo version = 3.3.0 try: myresults =…
Sarthak Gupta
  • 824
  • 12
  • 23
0
votes
3 answers

Pymongo: How to access the field value of an object in a nested array in a Projection?

I'm trying to code a projection in pymongo (3.3.0, Python 3.6.0, MongoDB 3.2). The original data is approximately of the form: { "_id" : ObjectId("592fd5ac1aee05abb6104912"), "Results" : { "SomeData" : 1234, …
Mol1hua
  • 1
  • 4
0
votes
0 answers

MongoDB using pymongo: insert the data as per extraction

I am having a json file containing the following typ of data: …
Jaffer Wilson
  • 7,029
  • 10
  • 62
  • 139
0
votes
2 answers

PyMongo and Django

I'm new to Django and I'm making a Django app where I'm supposed to use MySQL and MongoDB through py-mongo. (I'm trying to use only py-mongo, not with mongoengine) I created an app 'test-app' with a model 'Books' and a CRUD views which seem to work…
Kemeia
  • 826
  • 2
  • 9
  • 24
0
votes
1 answer

Displaying embedded data in Mongo DB with Python

I am working on a project with Flask and Mongo DB and I want to display some embedded documents. I am not really getting error messages but the data is not displaying how I want it to. Currently, my documents look like this: { "_id" :…
ravenUSMC
  • 495
  • 5
  • 23
0
votes
1 answer

Pymongo KeyError: '$err' MongoDB Atlas

I'm following this https://www.mongodb.com/blog/post/getting-started-with-python-and-mongodb introductory tutorial. I can connect to the cluster fine with mongo shell, but not with pymongo (Python: 3.6.1, Pymongo 3.4.0). Pymongo works okay with a…
belteshazzar
  • 2,163
  • 2
  • 21
  • 30