from pymongo.mongo_client import MongoClient from pymongo.server_api import ServerApi uri = "mongodb+srv://charlescpalmer:LNxzmBXYPvvZocxe@dartmouthwi25cluster0.xnmn6.mongodb.net/?retryWrites=true&w=majority&appName=DartmouthWI25Cluster0" # Create a new client and connect to the server client = MongoClient(uri, server_api=ServerApi('1')) # Send a ping to confirm a successful connection try: client.admin.command('ping') print("Pinged your deployment. You successfully connected to MongoDB!") except Exception as e: print(e)