标签:python mongodb idf grid file except for int name
import pymongo; #MongoDB操作模块
import gridfs; #存储桶
client = pymongo.MongoClient("mongodb://localhost:27017") #获得数据库连接
db = client["trs"] #指定数据库表
fs = gridfs.GridFS(db) #获取gridfs对象
fsb = gridfs.GridFSBucket(db)
files = fs.find()
try:
i=1
for file in files:
print("["+str(i)+"]""finename is :" + file.name)
file = fs.find_one({"filename":file.name})
local = open(str(file._id),‘wb+‘)
stream = fsb.download_to_stream(file._id,local)
i=i+1
except Exception as e:
print(str(e))
标签:python mongodb idf grid file except for int name
原文地址:https://www.cnblogs.com/fottencity/p/13368714.html