↻
⏵︎ Run
import pymongo myclient = pymongo.MongoClient("mongodb://localhost:27017/") #use database named "organisation" mydb = myclient["organisation"] #use collection named "developers" mycol = mydb["developers"] #list of documents list = [{ "name": "Kiku", "address": "Germany" }, { "name": "Lini", "address": "Sweden" }, { "name": "Sree", "address": "India" }, { "name": "Raghu", "address": "India" }, { "name": "Mams", "address": "France" }] #insert multiple documents x = mycol.insert_many(list) print('ids of inserted documents\n---------------------') for id in x.inserted_ids: print(id)
Output