1

I am trying to count in my mongodb profiler data all the documents, that have been moved when they were updated.

In the mongo shell I do this via:

db.system.profile.find({op:"update", moved:true}).count()

which works fine. But now I want to incorporate this into a python script where I am using pymongo.

My attempt looks like this:

db.system.profile.find({'op':"update"},{'moved':"true"}).count()

but I get the error message: name 'moved' is not defined.

I read the pymongo docu and did quite a bit of research and tried to understand how pymongo is treating the find command as in Using .sort with PyMongo or here: http://blog.pythonisito.com/2012/01/moving-along-with-pymongo.html

but I don't find a solution. Any help would be greatly appreciated. Thanks!

Community
  • 1
  • 1
  • I found a workaround for my problem. I am now looking for the nmoved tag instead like that: db.system.profile.find({'nmoved':{'$gt': 0}}).count(). Nevertheless I still would be interested in a solution for my initial question. – coffeedrinker Oct 14 '13 at 21:27

1 Answers1

2

Like this:

db.system.profile.find({'op': 'update', 'moved': True}).count()

Just like in the shell.

A. Jesse Jiryu Davis
  • 23,641
  • 4
  • 57
  • 70