Questions tagged [pymongo]

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.

Documentation

Related Links

Related Tags

6819 questions
2
votes
1 answer

mongo document with only keys inside keys, how to do a find on key range

I have a Document which looks like this { "2014" : { "11" : { "20" : { "Counts" : { "c" : 2 } }, "21" : { "Counts" : { …
Brij Raj Singh - MSFT
  • 4,903
  • 7
  • 36
  • 55
2
votes
1 answer

Create a map using pymongo

I have document with fields: a, b, c, d Currently if I iterate over the collection with such documents, I get the full dictionary as output. Is there a way to get output in a key value pair with value of b as key and rest of the information as…
Anuj
  • 1,160
  • 2
  • 20
  • 40
2
votes
1 answer

pymongo.errors.ConnectionFailure: timed out from an ubuntu ec2 instance running scrapyd

So... I'm running scrapyd on my ubuntu ec2 instance after following this post: http://www.dataisbeautiful.io/deploying-scrapy-ec2/ however I guess I can't get pymongo to connect to my MongoLabs mongo database, since the ubuntu ec2 scrapyd logs are…
pyramidface
  • 1,207
  • 2
  • 17
  • 39
2
votes
2 answers

Mongodb update guarantee using w=0

I have a large collection with more that half a million of docs, which I need to updated continuously. To achieve this, my first approach was to use w=1 to ensure write result, which causes a lot of delay. collection.update( {'_id': _id}, …
Dewsworld
  • 13,367
  • 23
  • 68
  • 104
2
votes
3 answers

Insert the $currentDate on mongodb with pymongo

I need test the accuracy of a server mongodb. I am trying to insert a sequence of data, take the moment and it was sent to the database to know when it was inserted. I'm trying this: #!/usr/bin/python from pymongo import Connection from datetime…
carlaodev
  • 621
  • 2
  • 8
  • 18
2
votes
1 answer

filtering boolean value on aggregate method in pymongo

I'm trying to use the aggregate method on pymongo like so: fnObjs.aggregate([ {'$match': {'sha1_duplicate': false}} ]) I'm getting : NameError: global name 'false' is not defined The query does works on the mongo cli.
gigman
  • 213
  • 2
  • 9
2
votes
2 answers

PyMongo’s bulk write operation features with generators

I would like to use PyMongo’s bulk write operation features which executes write operations in batches in order to reduces the number of network round trips and increaseses rite throughput. I also found here that it was possible to used 5000 as a…
user977828
  • 7,259
  • 16
  • 66
  • 117
2
votes
1 answer

Finding document based on date range works in the mongodb shell, but not with pymongo

On the mongo shell this returns a document just fine: > db.orderbook_log.findOne({'time': { '$gte': new Date(2014, 9, 24, 17, 38, 20, 546000), '$lt': new Date(2014, 10, 24, 17, 39, 20, 546000)}}) //... returns document with this time stamp: …
nak
  • 3,077
  • 3
  • 27
  • 35
2
votes
1 answer

insert fields of numpy structured array into mongodb

I'm currently investigating if it is possible to use structured numpy arrays more or less directly as documents for mongodb insert operations. In all examples I have found db.collection.insert(doc) doc is always a Python dict, but I wonder if not…
Dominik Neise
  • 1,179
  • 1
  • 10
  • 23
2
votes
1 answer

Does ordered dictionary (python) matter w.r.t compound indexes?

Ordering in compound indexes matter. But does the ordering in reads/writes matter? Is mongodb smart enough to reorder the fields based on indexes available? The code is in python. I read that it is preferable to pass in ordered dictionary using:…
shrnkrn
  • 121
  • 1
  • 9
2
votes
1 answer

Remove a PyMongo SON Manipulator

For some queries in my application, I am using a SON manipulator to conveniently render database output. In some other cases, I just want the raw data. So I add my manipulator thus: db.add_son_manipulator(Renderer()) And here's my Renderer: class…
sssilver
  • 2,549
  • 3
  • 24
  • 34
2
votes
0 answers

Mongodb with very high CPU rate

When I ran the following code and killed it immediately(that means to abnormally exit), the CPU rate of Mongodb would go extremely high(around 100%): #-*- encoding:UTF-8 -*- import threading import time import pymongo single_conn =…
zczhuohuo
  • 169
  • 1
  • 13
2
votes
1 answer

Index for query with "field": {$not: {$elemmatch: {...}}?

Why is this query not using this index when searching documents like these? My Query: { "unique_contact_method.enrichments": { "$not": { "$elemMatch": { "created_by.name":enrichment_name }}}} My Index: { key: {…
Jordan Warbelow-Feldstein
  • 10,510
  • 12
  • 48
  • 79
2
votes
1 answer

Sorting nested fields in MongoDB

I have the following data structure: { 'url' : 'www.example.com', 'title' : 'This is a title', 'data' : [ [{'name': 'abcdefg'}, {'nmr': 'hijklmnop'}], [{'name': 'hijklmnop'}, {'nmr': 'abcdefg'}] ] }, { …
chemist
  • 373
  • 9
  • 20
2
votes
1 answer

Cursor not found when using parallel scan of Pymongo

I have a mongo database with a collection of 3.000.000 documents that I process with pymongo. I want to iterate once through all documents without updating the collection. I tried to do that using four threads: cursors =…
filippia
  • 23
  • 4
1 2 3
99
100