I
I
Ivanzolo20012021-09-02 19:58:46
Python
Ivanzolo2001, 2021-09-02 19:58:46

Why is pymongo throwing an error?

Understanding how to work with pymongo. Wrote a simple code.

from pymongo import MongoClient
cluster = MongoClient("mongodb+srv://тут мое имя:<мой пароль>@cluster0.7xxw7.mongodb.net/testbase(это имя моей бд)?retryWrites=true&w=majority")
db = cluster["testbase"]
collection = db["users"]
name = input("> ")
collection.insert_one({"_id":1, "name": name, "balance":random.randint(1, 100)})


Gives an error message
raise OperationFailure(errmsg, code, response, max_wire_version)
pymongo.errors.OperationFailure: bad auth : Authentication failed., full error: {'ok': 0, 'errmsg': 'bad auth : Authentication failed.', 'code': 8000, 'codeName': 'AtlasError'}

Answer the question

In order to leave comments, you need to log in

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question