admin管理员组文章数量:1401939
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 ?
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 ?
Share Improve this question asked Mar 24 at 18:47 user3732793user3732793 1,9807 gold badges29 silver badges57 bronze badges1 Answer
Reset to default 1value
is a reserved keyword. Used in statements like SELECT VALUE...
You can either use a different property name or d["value"]
.
本文标签: pythonselect value does fail in cosmo dbStack Overflow
版权声明:本文标题:python - select value does fail in cosmo db - Stack Overflow 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1744233282a2596439.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论