upsert() takes one of two shapes:
Parameters
Shape 1: list of item dicts
Each dict can contain:
contents accepts a str or bytes. Strings are stored as-is; bytes are base64-encoded first. get() always returns contents as a str, so bytes come back as their base64 text: decode them with base64.b64decode().
datetime and date objects in metadata are converted to integer epoch milliseconds before being sent (naive datetimes are treated as UTC; sub-millisecond precision is truncated). Values read back with get() come back as the same integer, not a datetime. The same conversion runs on filter dicts passed to query() / query_binary() / query_metadata(), so a {"created": {"$gte": datetime(...)}} predicate works directly. See Dates.Shape 2: parallel arrays
Shape 2 can’t attach metadata or contents. To send them with parallel arrays, call
upsert_binary() directly.
Returns
None
Exceptions
cyborgdb.ValidationError
cyborgdb.ValidationError
- The arguments don’t match either shape (also a
TypeError), an item has noid, or the IDs and vectors differ in length. Raised before any request is sent. - The service rejects the items (HTTP
400), for example a vector with the wrong dimension.
cyborgdb.AuthenticationError
cyborgdb.AuthenticationError
The
index_key or api_key is invalid (HTTP 401).cyborgdb.ServiceError
cyborgdb.ServiceError
The service returns
5xx.cyborgdb.TransportError
cyborgdb.TransportError
The service can’t be reached.