我想在mongodb集合中存储来自文件夹的多个图像。我开始如下:
import pymongo
from pymongo import MongoClient
client = MongoClient('localhost', 27017) # I connected to the mongo instance running on the system
db = client['database1'] # I connected to the required data base
如果我要创建一个集合并在其中插入数据,我会执行以下操作:
people = db['details'] #I created a new collection named people.
p1 = { "name" : "Dravid", "age" : 22 }
people.insert(p1)
但是,我想创建一个集合(比如“图像”)并将图像从文件夹插入到这个新集合中(文件夹的路径已知)。可能吗 ?如果是,我该怎么办?以及如何可视化存储在数据库中的图像?