推薦閱讀數據庫
from io import BytesIO
import bson
import pymongo
import requests
conn = pymongo.MongoClient(host='127.0.0.1', port=27017)
db = conn.數據庫名
collection = db.表名
img = BytesIO(requests.get(url='圖片連接').content)
collection.save(dict(_id='ID', img=bson.binary.Binary(img.getvalue())))
conn.close()
複製代碼