I am trying to do some simple stuff with my pymongo with a staging database. so the first thing as usual
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')
and now just
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.
or even to check the version !?
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 . . .
any suggestion ?!
Best Answer
Why should
work?
You are guessing API methods without having read the basics about MongoDB and PyMongo.
find() is obviously a method of a collection and not of the connection.
is what you what.
Please read the docs before tinkering and guessing how API are to be used.
The PyMongo documentation is full of examples.