MongoDB
时间:2021-07-01 10:21:17
帮助过:21人阅读
pymongo
def connect_mongo():
client = pymongo.MongoClient(host=
‘10.0.0.200‘, port=27017
)
db = client[
‘lxfdb‘]
# 连接数据库
db.authenticate(
"root",
"123456")
# 认证用户
return db
db =
connect_mongo()
ret = db.collection.find()
# find等于查找集合所有数据,得到的是个可迭代对象
for i
in ret:
print(i)
MongoDB
标签:port pymongo client col pip god nbsp style class