El objeto de colección no es un error invocable con PyMongo
Siguiendo a lo largo del PyMongotutorial y recibo un error al llamar alinsert_one
método en una colección.
In [1]: import pymongo
In [2]: from pymongo import MongoClient
In [3]: client = MongoClient()
In [4]: db = client.new_db
In [5]: db
Out[5]: Database(MongoClient('localhost', 27017), u'new_db')
In [6]: posts = db.posts
In [7]: posts.insert_one({'a':1})
---------------------------------------------------------------------------
TypeError Traceback (most recent call last)
<ipython-input-7-2271c01f9a85> in <module>()
----> 1 posts.insert_one({'a':1})
C:\Anaconda\lib\site-packages\pymongo-2.8-py2.7-win32.egg\pymongo\collection.py in __call__(self, *a
rgs, **kwargs)
1771 "call the '%s' method on a 'Collection' object it is "
1772 "failing because no such method exists." %
-> 1773 self.__name.split(".")[-1])
TypeError: 'Collection' object is not callable. If you meant to call the 'insert_one' method on a 'Collection' object it is failing because no such method exists.
Hay algunas publicaciones en línea que analizan este error, pero todas parecen ser cuando el usuario llama a un nombre obsoleto.
¿Alguna guía sobre lo que estoy haciendo mal aquí?