作者:手机用户3312丿075454 | 来源:互联网 | 2023-05-17 14:11
首先,安装python支持的mongodb库pipinstallpymongofrompymongoimportMongoClientclientMongoClient('
首先,安装python支持的mongodb库pip install pymongo
from pymongo import MongoClient
client = MongoClient('localhost',27017)
#获取所有数据库
dblist = client.list_database_names()
print("数据库列表:",dblist)
choosedb = client['olddream']
#获取选定数据库的所有集合
collectiOns= choosedb.list_collection_names()
print("选定数据库的集合列表:",collections)