如何通过Python正确查询Azure表的时间戳?

2024-05-15 07:34:29 发布

您现在位置:Python中文网/ 问答频道 /正文

我希望使用Python运行查询的结果与在azureportal中相同

在Azure Cosmos表中,我有两行具有时间戳的实体UserOpinion: 2019年10月21日星期一10:56:04 GMT; 2019年10月21日星期一11:32:49 GMT

查询时间戳ge datetime'2019-10-16T18:11:36.378Z' 结果在Azure门户内部返回2行。你知道吗

table_service = TableService(endpoint_suffix="table.cosmos.azure.com", connection_string=connection_string) 
objects = table_service.query_entities("UserOpinion", filter = "Timestamp ge datetime'2019-10-16T18:11:36.378Z'" )

Python返回的对象列表是空的,但它不会引发任何格式异常


Tags: 实体datetimestring门户service时间tableconnection
1条回答
网友
1楼 · 发布于 2024-05-15 07:34:29

请尝试将日期时间的比较更改为以下内容:

filter = "Timestamp gt datetime'" + '2019-10-16T18:11:36.378Z'+ "'"

你也可以试试下面的东西:

table_service.query_entities('DeviceData', "Timestamp gt datetime'2016-05-01T00:00:00.000Z'")

附加参考:

https://github.com/Azure/azure-storage-python/issues/202

希望有帮助。你知道吗

相关问题 更多 >