我已经在 Heroku 上部署了这个 Python 应用程序,我希望它连接到 MongoDB Atlas 集群。我用我的字符串连接到集群,但由于某种原因,我不断raise OperationFailure(msg % errmsg, code, response)
pymongo.errors.OperationFailure: bad auth Authentication failed.检查两次,用户和密码都正确。知道为什么会这样吗?
from pymongo import MongoClient
import time
import random
import time
import datetime
client = MongoClient('mongodb+srv://USER:<MYPASSWORD>@test-2liju.mongodb.net/test?retryWrites=true')
db = client.one
mycol = 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)
人到中年有点甜
狐的传说
SMILET
相关分类