new to cosmoDB tried this and it worked fine
cosmos_db = cosmos_client.create_database_if_not_exists("Test_DB")
container = cosmos_db.create_container_if_not_exists("test_data", PartitionKey(path='/id', kind='Hash'))
container.create_item({"id": "1", "value": "foo"})
container.upsert_item({"id": "2", "value": "bar"})
container.upsert_item({"id": "3", "value": "HelloWorld"})
item = container.read_item("1", partition_key="1")
assert item["value"] == "foo"
queryText = "SELECT * FROM test_data d where d.id = '1'"
results = container.query_items(query=queryText,
enable_cross_partition_query=False,
)
items = [item for item in results]
works for both the query and the read_item. When I use
queryText = "SELECT * FROM test_data d where d.value = 'foo'"
it fails wild and with
Code: BadRequest
Message: Failed to parse token 'value' at position 36
is there a way to avoid the big stack trace and even better to query for foo ?
value
is a reserved keyword. Used in statements like SELECT VALUE...
You can either use a different property name or d["value"]
.