1

私のコードで何が起こっているのかを理解するのに苦労しています:

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)

これで私には2つのことが起こっています。最初のクエリは、次のレコードの URL に /services/data/v38.0/query/01gf000000gFYRwAAO-2000 を提供しますが、nextQuery は /services/data/v38.0/query/01gf000000gFYRwAAO-4000 を提供しますが、これは奇妙ですチャンク量を変更していること。

起こっているもう 1 つのことは、次のチャンクが決して終わらないということです。リストされているオブジェクトには約 95K 行が含まれているため、理論的には 4000 で約 25 ファイル、または 2000 で 48 ファイルを吐き出すはずです。私のオブジェクトなので、ファイルを分割して書き込む必要があります。このコードを正しく機能させるにはどうすればよいですか?

4

1 に答える 1