我无法检索 Table_Service 的 query_entities 的属性
I can not retrieve attribute of query_entities of Table_Service
我的查询应该 return 超过 1000 行。但是,query_entities return 一次查询只有 1000 行。
因此,我想在结果查询超过 1000 行时使用返回的令牌来获取查询应 return 编辑的所有行。但我无法检索 x-ms-continuation 属性。
#coding:utf-8
class Use_Azure_Data:
def __init__(self, account_name, sas_token):
self._account_name = account_name
self._sas_token = sas_token
#Auth
def _set_table_service(self):
table_service = TableService(account_name=self._account_name, sas_token=self._sas_token)
return(table_service)
def Retrives_datas(self, days_before):
before_now = datetime.datetime.now() - datetime.timedelta(days=days_before)
now = before_now.isoformat()
filter = "Timestamp gt datetime'" + now + "'"
Query = self.Table_Service.query_entities('MyTable', filter = filter, timeout=None)
if hasattr(Query, 'x-ms-continuation'):
print("x-ms-continuation attribut for Query EXIST.")
else:
print("x-ms-continuation attribut for Query NOT EXIST.
Table_Service = property(_set_table_service)
Data = Use_Azure_Data('MyAccount', 'MySASkey' )
Data.Retrives_datas(7)
查询存在的 x-ms-continuation 属性。
我想检索 x-ms-continutation 以使用它来获取我的查询应检索的所有行
如果您使用的是 azure-cosmosdb-table 的最新软件包,您应该使用 marker
而不是 x-ms-continuation
。
示例代码如下:
table_service = TableService(account_name, account_key)
i=0
marker = None
while True:
tasks = table_service.query_entities(table_name, data_filter,
marker = marker,
num_results=1000)
for task in tasks:
i += 1
print(task)
if tasks.next_marker is not None and len(tasks.next_marker) > 0:
marker = tasks.next_marker
else:
break
print i
您可以查看 query_entities on GitHub 的定义:
我的查询应该 return 超过 1000 行。但是,query_entities return 一次查询只有 1000 行。 因此,我想在结果查询超过 1000 行时使用返回的令牌来获取查询应 return 编辑的所有行。但我无法检索 x-ms-continuation 属性。
#coding:utf-8
class Use_Azure_Data:
def __init__(self, account_name, sas_token):
self._account_name = account_name
self._sas_token = sas_token
#Auth
def _set_table_service(self):
table_service = TableService(account_name=self._account_name, sas_token=self._sas_token)
return(table_service)
def Retrives_datas(self, days_before):
before_now = datetime.datetime.now() - datetime.timedelta(days=days_before)
now = before_now.isoformat()
filter = "Timestamp gt datetime'" + now + "'"
Query = self.Table_Service.query_entities('MyTable', filter = filter, timeout=None)
if hasattr(Query, 'x-ms-continuation'):
print("x-ms-continuation attribut for Query EXIST.")
else:
print("x-ms-continuation attribut for Query NOT EXIST.
Table_Service = property(_set_table_service)
Data = Use_Azure_Data('MyAccount', 'MySASkey' )
Data.Retrives_datas(7)
查询存在的 x-ms-continuation 属性。
我想检索 x-ms-continutation 以使用它来获取我的查询应检索的所有行
如果您使用的是 azure-cosmosdb-table 的最新软件包,您应该使用 marker
而不是 x-ms-continuation
。
示例代码如下:
table_service = TableService(account_name, account_key)
i=0
marker = None
while True:
tasks = table_service.query_entities(table_name, data_filter,
marker = marker,
num_results=1000)
for task in tasks:
i += 1
print(task)
if tasks.next_marker is not None and len(tasks.next_marker) > 0:
marker = tasks.next_marker
else:
break
print i
您可以查看 query_entities on GitHub 的定义: