我已经在 Heroku 上部署了这个 Python 应用程序,我希望它连接到 MongoDB Atlas 集群。我用我的字符串连接到集群,但由于某种原因,我不断raise OperationFailure(msg % errmsg, code, response)pymongo.errors.OperationFailure: bad auth Authentication failed.检查两次,用户和密码都正确。知道为什么会这样吗?from pymongo import MongoClientimport timeimport randomimport timeimport datetimeclient = MongoClient('mongodb+srv://USER:<MYPASSWORD>@test-2liju.mongodb.net/test?retryWrites=true')db = client.onemycol = client["tst"]while True: test = int(random.randrange(-99999990,90000000,1)) dic = {"num": test} result = db.tst.insert_one(dic) print(test) time.sleep(5)
3 回答
添加回答
举报
0/150
提交
取消