Python 查找方法不';不存在于pymongo或版本中?

Python 查找方法不';不存在于pymongo或版本中?,python,pymongo,Python,Pymongo,我试图用我的pymongo做一些简单的事情,使用一个临时数据库。所以第一件事和往常一样 import pymongo connection = pymongo.Connection(host = 'mongodb://username:password@alaki-staging.member0.mongolayer.com:37017,/dbname?safe=true&slaveOk=true&fsync=true&journal=true&ssl=true'

我试图用我的pymongo做一些简单的事情,使用一个临时数据库。所以第一件事和往常一样

import pymongo
connection = pymongo.Connection(host = 'mongodb://username:password@alaki-staging.member0.mongolayer.com:37017,/dbname?safe=true&slaveOk=true&fsync=true&journal=true&ssl=true')
现在

connection.find({})
> Traceback (most recent call last):
  File "D:\MypythonCode\test.py", line 7, in <module>
    connection.find({})
  File "C:\Python27\lib\site-packages\pymongo\database.py", line 769, in __call_
_
    self.__name, self.__connection.__class__.__name__))
TypeError: 'Database' object is not callable. If you meant to call the 'find' me
thod on a 'Connection' object it is failing because no such method exists.

C:\Python27>python.exe D:\MypythonCode\test.py > test.d
Traceback (most recent call last):
  File "D:\MypythonCode\test.py", line 7, in <module>
    connection.find({})
  File "C:\Python27\lib\site-packages\pymongo\database.py", line 769, in __call_
_
    self.__name, self.__connection.__class__.__name__))
TypeError: 'Database' object is not callable. If you meant to call the 'find' me
thod on a 'Connection' object it is failing because no such method exists.
connection.find({})
>回溯(最近一次呼叫最后一次):
文件“D:\MypythonCode\test.py”,第7行,在
连接。查找({})
文件“C:\Python27\lib\site packages\pymongo\database.py”,第769行,在调用中_
_
self.\uuuuu名称,self.\uuuuu连接.\uuuuuu类\uuuuuuuuuuu名称uuuuuuuu))
TypeError:“数据库”对象不可调用。如果你想打电话给“找到”我
thod在“Connection”对象上失败,因为不存在这样的方法。
C:\Python27>python.exe D:\MypythonCode\test.py>test.D
回溯(最近一次呼叫最后一次):
文件“D:\MypythonCode\test.py”,第7行,在
连接。查找({})
文件“C:\Python27\lib\site packages\pymongo\database.py”,第769行,在调用中_
_
self.\uuuuu名称,self.\uuuuu连接.\uuuuuu类\uuuuuuuuuuu名称uuuuuuuu))
TypeError:“数据库”对象不可调用。如果你想打电话给“找到”我
thod在“Connection”对象上失败,因为不存在这样的方法。
甚至检查版本

connection.version()

Traceback (most recent call last):
  File "test.py", line 7, in <module>
    connection.version()
  File "C:\Python27\lib\site-packages\pymongo\database.py", line 769, in __call_
_
    self.__name, self.__connection.__class__.__name__))
TypeError: 'Database' object is not callable. If you meant to call the 'version'
 method on a 'Connection' object it is failing because no such method exists.
Press any key to continue . . .
connection.version()
回溯(最近一次呼叫最后一次):
文件“test.py”,第7行,在
connection.version()
文件“C:\Python27\lib\site packages\pymongo\database.py”,第769行,在调用中_
_
self.\uuuuu名称,self.\uuuuu连接.\uuuuuu类\uuuuuuuuuuu名称uuuuuuuu))
TypeError:“数据库”对象不可调用。如果你想称之为“版本”
“连接”对象上的方法失败,因为不存在此类方法。
按任意键继续。
有什么建议吗

为什么要这样做

connection.find({}) 
工作

您在猜测API方法时没有阅读MongoDB和PyMongo的基础知识

find()显然是一个集合而不是连接的方法

row = connection.your_collection.find()
是什么你什么

在修补和猜测API将如何使用之前,请先阅读文档


PyMongo文档中充满了示例。

-1表示不思考。您正在对连接对象而不是集合调用find()。为什么连接应该实现find()?find()是集合的功能。求你了,你他妈的是对的!我正在查询连接!请随意删除该问题!我想用-1来形容你的傲慢。这也是一个人们提问并得到回应的地方。如果你不喜欢这个问题,你可以很容易地避免回答。作为旁注:您可以轻松地使用RTF网络礼仪。