📜  pymongo 将 json 添加到集合中 - Javascript 代码示例

📅  最后修改于: 2022-03-11 15:01:11.897000             🧑  作者: Mango

代码示例1
client = MongoClient('localhost', 27017)
db = client['countries_db']
collection_currency = db['currency']

with open('currencies.json') as f:
    file_data = json.load(f)

collection_currency.insert(file_data) # pymongo < 3.0
collection_currency.insert_one(file_data) # pymongo >= 3.0
collection_currency.insert_many(file_data) # pymongo >= 3.0

client.close()