Note that there are some explanatory texts on larger screens.

plurals
  1. POMongoDB crashes on serial update (pymongo)
    primarykey
    data
    text
    <p>I wrote a simple script to do a collection-wide update on my <code>events</code> collection inside my <code>motivate_testing</code> db. Here's the script:</p> <pre><code>#!/usr/bin/env python from django.db import models from django.conf import settings from pymongo import MongoClient from apps.motiv8 import models # Mongo setup client = MongoClient() db = client[settings.MONGO_DB_NAME] for event in db.events.find(): try: course = models.Course.objects.get(id=event['course_id']) except: continue organization = course.organization db.events.update({"course": event['course_id']}, {"$set": {"organization_id": int(organization.id)} }) </code></pre> <p>Every time I run this, I get this error:</p> <pre><code>Traceback (most recent call last): File "./add_org_to_events_db.py", line 27, in &lt;module&gt; db.events.update({"course": event['course_id']}, {"$set": {"organization_id": int(organization.id)} }) File "/opt/motiv8/lib/python2.6/site-packages/pymongo/collection.py", line 487, in update check_keys, self.__uuid_subtype), safe) File "/opt/motiv8/lib/python2.6/site-packages/pymongo/mongo_client.py", line 956, in _send_message sock_info = self.__socket() File "/opt/motiv8/lib/python2.6/site-packages/pymongo/mongo_client.py", line 773, in __socket "%s %s" % (host_details, str(why))) pymongo.errors.AutoReconnect: could not connect to localhost:27017: [Errno 111] Connection refused </code></pre> <p>Which crashes mongo entirely. I have about 9000 records inside this collection. What am I doing wrong? For a database touted for its "speed" and "concurrency," MongoDB is severely disappointing me. It seems as if I'm running the connection into the ground.</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload