【发布时间】:2015-10-03 23:29:00
【问题描述】:
我是 python tornado 框架的新手。我在 MongoDB 中有一小部分数据。我在我的 python 文件中使用了一个简单的 get 函数。使用db.collection.find() 选项时,我得到BadYieldError。但是db.collection.find_one() 工作正常,但它只显示一条记录。
import tornado
import bson
from bson import json_util
from bson.json_util import dumps
class TypeList(APIHandler):
@gen.coroutine
def get(self):
doc = yield db.vtype.find()
self.write(json_util.dumps(doc))
错误是:
tornado.gen.BadYieldError: 产生未知对象 MotorCursor()
【问题讨论】:
标签: python json mongodb tornado-motor