How to iterate all databases in PyMongo
This short example shows how to iterate all databases or list all database names for a MongoDB in Python using pymongo
:
from pymongo import MongoClient
client = MongoClient("mongodb://localhost")
for database in client.list_databases():
print(database['name'])
s
If this post helped you, please consider buying me a coffee or donating via PayPal to support research & publishing of new posts on TechOverflow