client = MongoClient(conn)
db = client.get_default_database()
json_file = {'test_1':1, 'test_2':2}
db.insert_one(json_file)
生成:
TypeError: 'Collection' object is not callable. If you meant to call the 'insert_many' method on a 'Database' object it is failing because no such method exists.
检查我的 pymongo 版本:
$ pip freeze | grep pymongo
$ pymongo==3.2.2
我认为这意味着insert_one
andinsert_many
方法应该可用(post pymongo 3.0
,对吗?)。更令人困惑的是,当我打电话时,dir(db)
我根本看不到对任何insert
方法的任何引用。
我错过了什么?