Python SDK bulk upsert?



  • Couchbase Server 7.2
  • couchbase==4.1.2(python package)

Is there a way to bulk upsert to a couchbase bucket collection using the python SDK ?

Currently upserting one document at a time.

def upsert_document(cb_coll: "couchbase.collection.Collection", doc: dict) -> None:
    """Upsert a document into the Couchbase collection."""
    key = f"{doc['record_date']}_{doc['id']}"
        result = cb_coll.upsert(key, doc)"Upserted document with CAS: %s", result.cas)
    except Exception as e:
        logger.error("Error upserting document: %s", e)

Hi @ii, and welcome to the forums!

upsert_multi is probably what you are looking for - please see the documentation here.

1 Like

This topic was automatically closed 90 days after the last reply. New replies are no longer allowed.