Example #1
0
def remove_blank_documents(db, coll):
    """
    Removes documents from database which have empty
    'text' fields
    """
    results = collection(db, coll).find({"text": ""}, fields=["_id"])
    for r in results:
        #        print r
        collection(db, coll).remove({'_id': r['_id']})
Example #2
0
def remove_blank_documents(db,coll):
    """
    Removes documents from database which have empty
    'text' fields
    """
    results = collection(db,coll).find({"text":""},  fields=["_id"])
    for r in results:
#        print r
        collection(db,coll).remove({'_id':r['_id']})
Example #3
0
    def process(self, msg):
        """
        Write documents in the database and collection in batches of size
        self.batchsz
        """
        #        print msg
        coll = collection(msg.pop('database'), msg.pop('collection'))
        self.insertlist.append(msg)

        if len(self.insertlist) > self.batchsz:
            print "==> inserting...",
            coll.insert(self.insertlist)
            self.insertlist = []
Example #4
0
    def process(self,  msg):
        """
        Write documents in the database and collection in batches of size
        self.batchsz
        """
#        print msg
        coll = collection(msg.pop('database'),msg.pop('collection'))
        self.insertlist.append(msg)
        
        if len(self.insertlist) > self.batchsz:
            print "==> inserting...", 
            coll.insert(self.insertlist)
            self.insertlist = []