如何在 PyMongo 中迭代所有数据库
此简短示例展示如何使用 pymongo 在 Python 中迭代 MongoDB 的所有数据库或列出所有数据库名称:
list_databases.py
from pymongo import MongoClient
client = MongoClient("mongodb://localhost")
for database in client.list_databases():
print(database['name'])s
Check out similar posts by category:
Python
If this post helped you, please consider buying me a coffee or donating via PayPal to support research & publishing of new posts on TechOverflow