MCPcopy Create free account
hub / github.com/cosdata/cosdata / upsert

Function upsert

tests/test-key-value-store.py:65–70  ·  view source on GitHub ↗
(name, txn_id, key: str, value: str)

Source from the content-addressed store, hash-verified

63 raise Exception(f"Failed to abort transaction: {response.text}")
64
65def upsert(name, txn_id, key: str, value: str):
66 url = f"{client.base_url}/collections/{name}/transactions/{txn_id}/upsert"
67 data = {"vectors": [{"id": key, "bytes": list(value.encode("utf-8"))}]}
68 response = requests.post(url, headers=client._get_headers(), data=json.dumps(data), verify=client.verify_ssl)
69 if response.status_code not in [200, 204]:
70 raise Exception(f"Failed to upsert vectors: {response.text}")
71
72def bulk_upsert(name, txn_id, items: list[tuple[str, str]]):
73 """Upsert multiple key-value pairs in a single request"""

Callers 8

do_upsertFunction · 0.70
test_unicode_contentFunction · 0.70
test_special_charactersFunction · 0.70
test_large_valueFunction · 0.70
test_transaction_abortFunction · 0.70
test_binary_like_contentFunction · 0.70
test_key_variationsFunction · 0.70

Calls 1

_get_headersMethod · 0.45

Tested by

no test coverage detected