My question is a specification of how can i validate username password for mongodb authentication through pymongo?.
I\'m trying to connect to a MongoDB instance using
run in terminal :
python -m pip install pymongo[srv]
python file:
import pymongo
from pymongo import MongoClient
import urllib.parse
username = urllib.parse.quote_plus('username')
password = urllib.parse.quote_plus("password")
url = "mongodb+srv://{}:{}@cluster0-0000.mongodb.net/?retryWrites=true&w=majority".format(username, password)
# url is just an example (your url will be different)
cluster = MongoClient(url)
db = cluster['Sample']
collection = db['temporary']