MCPcopy Create free account
hub / github.com/IBM/AssetOpsBench / _bulk_insert

Function _bulk_insert

src/couchdb/loader.py:255–273  ·  view source on GitHub ↗
(db, docs, batch_size=500)

Source from the content-addressed store, hash-verified

253
254
255def _bulk_insert(db, docs, batch_size=500):
256 total = len(docs)
257 for i in range(0, total, batch_size):
258 batch = docs[i : i + batch_size]
259 r = requests.post(
260 _db_url(db, "_bulk_docs"), json={"docs": batch}, auth=_AUTH, timeout=60
261 )
262 r.raise_for_status()
263 errors = [x for x in r.json() if x.get("error")]
264 if errors:
265 logger.warning(
266 "%d bulk-insert errors in batch %d", len(errors), i // batch_size
267 )
268 logger.info(
269 "Inserted batch %d/%d (%d docs)",
270 i // batch_size + 1,
271 math.ceil(total / batch_size),
272 len(batch),
273 )
274
275
276# --------------------------------------------------------------------------- #

Callers 1

load_collectionFunction · 0.85

Calls 2

_db_urlFunction · 0.85
getMethod · 0.45

Tested by

no test coverage detected