本文整理汇总了Python中GlobalUtilities.queryCursorDB方法的典型用法代码示例。如果您正苦于以下问题:Python GlobalUtilities.queryCursorDB方法的具体用法?Python GlobalUtilities.queryCursorDB怎么用?Python GlobalUtilities.queryCursorDB使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类GlobalUtilities
的用法示例。
在下文中一共展示了GlobalUtilities.queryCursorDB方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: run
# 需要导入模块: import GlobalUtilities [as 别名]
# 或者: from GlobalUtilities import queryCursorDB [as 别名]
def run(self, settings_key, mode, job_id):
s = tools.getKey(settings_key).get()
if mode == "contacts":
query = s.data.all_contacts
num_results = 30
elif mode == "donations":
query = s.data.all_donations
num_results = 50
elif mode == "individuals":
query = s.data.all_individuals
num_results = 15
else:
raise Exception("Unidentified mode in GenerateReport")
blobs = []
cursor = None
# Create header CSV file
header_file_name = job_id + "-0.csv"
blobs.append((yield HeaderCSV(mode, header_file_name)))
while True:
results = tools.queryCursorDB(query, cursor, keys_only=True, num_results=num_results)
keys, cursor = results[0], results[1]
file_name = job_id + "-" + str(len(blobs)) + ".csv"
keys = tools.ndbKeyToUrlsafe(keys)
blobs.append((yield CreateCSV(mode, file_name, keys)))
if cursor == None:
break
final_file_name = s.name + "-" + mode.title() + ".csv"
gcs_file_key = yield ConcatCSV(job_id, final_file_name, *blobs)
yield ConfirmCompletion(job_id, gcs_file_key)