# Import the required library
import pymongo
# Set up the connection string for localhost
connection_string = "mongodb://localhost:27017/"
# Create a MongoDB client
client = pymongo.MongoClient(connection_string)
# Access a specific database
database = client["your_database_name"]
# Access a specific collection within the database
collection = database["your_collection_name"]
# Perform operations on the collection
# For example, find all documents in the collection
documents = collection.find({})
for document in documents:
print(document)