【发布时间】:2018-03-29 14:35:13
【问题描述】:
如果我想读取我的数据数据库 (mongoDB) 的所有集合,我使用方法 find() "print(db.collecion.find())" 我们完成了错误
错误:
“数据库”对象不可调用。如果您打算在 'MongoClient' 对象上调用 'find' 方法,它会失败,因为不存在这样的方法。
如何解决? 代码来源:
from pymongo import MongoClient
from pymongo import *
import os
import pprint
mongodb_host = 'localhost'
mongo_port = '27017'
client = MongoClient(mongodb_host + ':'+mongo_port)
db = client['test']
cl=db.client
try:
pprint.pprint(cl.find())
except Exception as e:
print ('this connection or insert are wrong.')
print (e)
错误:
“数据库”对象不可调用。如果您打算调用“查找” 'MongoClient' 对象上的方法失败,因为没有这样的方法 存在。
如何解决?
【问题讨论】:
-
请检查how to ask question 和Minimal, Complete, and Verifiable example 添加您的代码,您尝试了什么。