python
import json
from pymongo import MongoClient
# 连接 MongoDB 数据库
client = MongoClient('mongodb://localhost:27017/')
db = client['<数据库名>']
collection = db['<集合名>']
# 读取 JSON 文件并导入数据
with open('', 'r') as file:
data = json.load(file)
collection.insert_many(data)
顶一下
(0)
0%
踩一下
(0)
0%
- 相关评论
- 我要评论
-