xxxxxxxxxx
from pymongo import MongoClient
# Create a MongoDB client
client = MongoClient("mongodb://localhost:27017/")
# Access a database
db = client["your_database_name"]
# Access a collection
collection = db["your_collection_name"]
# Perform required operations on the collection
# For example, retrieve documents using collection.find(), insert new documents using collection.insert_one(), etc.
# Close the connection when you're done
client.close()