한 컬렉션에서 다른 컬렉션으로 레코드를 옮기는 적절한 방법은 무엇입니까? 나는 동일한 목표를 달성하는 거래를 가진 this과 같은 여러 다른 게시물을 보았지만 아무도 파이썬 구현을 가지고 있지 않습니다. 내가 insert_many를 사용하는 경우한 컬렉션에서 다른 컬렉션으로 레코드 이동하기
#Taking a number of records from one database and returning the cursor
cursor_excess_new = db.test_collection_new.find().sort([("_id", 1)]).limit(excess_num)
# db.test.insert_many(doc for doc in cursor_excess_new).inserted_ids
# Iterating cursor and Trying to write to another database
# for doc in cursor_excess_new:
# db.test_collection_old.insert_one(doc)
result = db.test_collection_old.bulk_write([
for doc in cursor_excess_new:
InsertMany(doc for each doc in cur)
pprint(doc)
])
, 나는 다음과 같은 오류가 발생합니다 : pymongo.errors.OperationFailure: Writes to config servers must have batch size of 1, found 10
bulk_write은 루프의 시작에서 나에게 구문 오류를주고있다.
pymongo의 한 컬렉션에서 다른 컬렉션으로 레코드를 전송하는 가장 좋은 방법 및 올바른 방법은 무엇입니까?