[BUG已解决]链接数据库MongoDB报错:
报错模板如下:
'Collection' object is not callable. If you meant to call the 'authenticate' method on a 'Database' object it is failing because no such method exists.
背景
在使用前后端分离项目,后端使用flask链接数据库MongoDB,之前跑的好好的,过了一段时间发现无法运行,显示数据库连接报错。 数据库已经部署到服务器!
解决方案:
出现下面这个bug,大多数是因为我们模块版本问题,应该是版本太高,不能支持之前的语法。
from pymongo import MongoClient
'Collection' object is not callable. If you meant to call the 'authenticate' method on a 'Database' object it is failing because no such method exists.
回退版本:
现在我的pymongo版本为4.4.1
我进入我的服务器上,发现版本为:3.9.0
那么我回退到3.9.0,,问题即可被解决!
项目成功启动,BUG解决:
'Collection' object is not callable. If you meant to call the 'authenticate' method on a 'Database' object it is failing because no such method exists.