Python으로 배우는 MongoDB 입문
Filip Schouwenaars
Machine Learning Researcher
from pymongo import InsertOne, UpdateOne # 클래스 임포트operations = [ InsertOne({ # 작업 1 "title": "Dune", "genre": ["action", "adventure", "drama"], "release_year": 2021, "rating": 8.0, "won_oscar": False }), UpdateOne( # 작업 2 { "title": "Titanic" }, { "$set": { "won_oscar": True } } ) ]result = mov.bulk_write(operations) # 리스트를 bulk_write에 전달
print(result.inserted_count)
1
print(result.modified_count)
1
유의 사항
다음을 혼합하여 사용 가능:
InsertOne()UpdateOne() / UpdateMany() / ReplaceOne()DeleteOne() / DeleteMany()ReplaceOne()다음에 적합:
Python으로 배우는 MongoDB 입문