我无法理解我的代码发生了什么:
import json
from simple_salesforce import Salesforce, SalesforceLogin
fileCount = 1
saveFilesPath ='<path>/'
fileName = saveFilesPath+'test_file'+str(fileCount)+'.json'
sf = Salesforce(username='<username>', password='<password>', security_token='<token>', domain='test' )
initialQuery = sf.query("SELECT id, name, createddate, lastmodifieddate FROM surveyquestionresponse__c")
nextChunk = initialQuery['nextRecordsUrl']
nextQuery = sf.query_more(nextChunk, True)
print(nextChunk)
print(nextQuery['nextRecordsUrl'])
#with open(fileName, 'w') as outfile :
# json.dump(initialQuery['records'],outfile)
#while nextQuery['nextRecordsUrl'] is not None :
# fileCount += 1
# fileName = saveFilesPath+'test_file'+str(fileCount)+'.json'
# print(nextQuery['nextRecordsUrl'])
# with open(fileName, 'w') as outfile :
# json.dump(nextQuery['records'], outfile)
有两件事发生在我身上。首先是初始查询为下一条记录 url 提供 /services/data/v38.0/query/01gf000000gFYRwAAO-2000,但接下来的 nextQuery 给出 /services/data/v38.0/query/01gf000000gFYRwAAO-4000 这很奇怪它正在改变块的数量。
正在发生的另一件事是下一个块永远不会结束。列出的对象中有大约 95K 行,所以理论上它应该吐出大约 25 个文件 @ 4000 或 48 个文件 @ 2000。由于 AWS 上 lambda 的内存限制和一些文件的大小,我无法使用 Query_All我的对象,所以我必须分段编写文件。我怎样才能让这段代码正常运行?