Script to list the names of all collections in a given MongoDB database using PyMongo.

from pymongo import MongoClient

#connect to local mongodb instance
client = MongoClient('localhost',27017)

#get the required mongodb database
db = client['my_db']

#get the list of all MongoDB collections in the database
collections = [collection_name for collection_name in db.list_collection_names()]Code language: PHP (php)