pymongo


python motor offers fetch_next exception on aggregation


I'm having difficulty with Motor's aggregation function giving a no fetch_next exception
The code is
cursor = db[collection].aggregate(myPipeline, cursor = {} )
if (yield cursor.fetch_next):
obj = bson.json_util.dumps(cursor.next_object())
self.write(obj)
that burped up the following
Exception: :'TracebackFuture' object
has no attribute 'fetch_next'
Then I tried the following that was found in a SO question
cursor = yield motor.Op(db[collection].aggregate, x_query)
that offered the same exception.
Running the aggregate in Mongo shell produces a bonafide result
"result" : [
{
"_id" : "Adam",
"num" : 110
},
{
"_id" : "Argyle",
"num" : 77
},
{
"_id" : "Net Valley",
"num" : 67
},
{
"_id" : "Notts Farm",
"num" : 64
},
{
"_id" : "Sam's Place",
"num" : 59
},
{
"_id" : "Tilly",
"num" : 58
},
{
"_id" : "Xavier",
"num" : 52
}
],
"ok" : 1
Motor has offered no such issue with find and `find_one. In fact, it works awesome otherwise.
Installation was done via pip install motor on Ubuntu.
Cheers
I'm sorry, the documentation is wrong. "aggregate" returns a Future, and you must yield the Future to get a cursor:
cursor = yield db[collection].aggregate(myPipeline, cursor={})
if (yield cursor.fetch_next):
obj = bson.json_util.dumps(cursor.next_object())
self.write(obj)
I've assigned myself a ticket, MOTOR-34, to track this issue for the next release.

Related Links

python motor offers fetch_next exception on aggregation
python motor mongo cursor length or peek next
PyMongo check if update succeeded
insert and query an OrderedDict in MongoHQ
Return .str of ObjectID using pymongo
Selecting the lowest/highest with find_one in Pymongo
Safe use of Pymongo's find_one
Pymongo $in + $regex
How can I get pymongo to always return str and not unicode?
SON Manipulator in mongo queries
How to append a document to a 2nd level embedded model list document in Django and mongoengine
pymongo multiple update $in
How to get negetive of a complex where clause in mongo db
pymongo justOne & multi
How to make pymongo's find() return a list?
convert pymongo cursor to json

Categories

HOME
webview
protocol-buffers
svn
automapper
android-fragments
redmine
devexpress
subdomain
ant
cryptography
openflow
dji-sdk
sympy
specifications
gtk
colors
multi-step
l20n
robolectric
renderscript
coreldraw
ini
sipp
backendless
environment
jstree
password-generator
high-availability
xdebug
iwebbrowser2
instructions
vcenter
progid
riotjs
lxml
osx-lion
adminer
cmis
android-canvas
transform
dreamfactory
orchardcms-1.8
nsuserdefaults
best-buy-api
opal-framework
reverse-dns
doctrine-extensions
linq-to-excel
karabiner
renderman
gestures
entropy
maven-jaxb2-plugin
case-when
openerp-6
ogg
cocoa-bindings
clp
oci
wicked-pdf
codecharge
timestamping
mercurial-extension
preferenceactivity
python-cffi
godeps
linuxbrew
stack-smash
nette
vdm-sl
quercus
htmltidy
tkx
directorysearcher
phonegap-facebook-plugin
password-recovery
cakephp-2.2
flurry-analytics
treeline
accessory
redpitaya
neo4jphp
fileshare
notifyjs
acceptance-testing
android-authenticator
multiple-dispatch
zend-pdf
clrprofiler
clearinterval
taskkill
representation
uipasteboard
startupscript
regression-testing
android-2.1-eclair
outlook-2007-addin
raw-data
data-retrieval
eai
tso
rakudo
regioninfo
downloadfile

Resources

Encrypt Message