Mengikuti tutorial PyMongo dan saya mendapatkan kesalahan saat memanggil metode insert_one
pada koleksi.
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.
Ada beberapa posting online yang membahas kesalahan ini tetapi semuanya tampaknya terjadi ketika pengguna memanggil nama yang tidak digunakan lagi.
Adakah panduan tentang kesalahan yang saya lakukan di sini?