本文介绍了无法使用Python从Salesforce获取完整记录的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试使用python中的 simple_salesforce 库从salesforce提取数据.

I am trying to fetch the data from salesforce using the simple_salesforce library in python.

运行计数查询时,我能够获得正确的记录计数.

I am able to get the correct count of records while running the count query.

但是,当我尝试将结果(以列表的形式)作为JSON对象放入s3时,持久存留的记录并没有像我从Salesforce捕获的记录那样多.

But while I am trying to put that results (in the form of list) into s3 as a JSON object, not as many reocrds are getting persisted as I captured from Salesforce.

这是代码段:

result = sf.query("SELECT ID FROM Opportunity")['records']
object.put(Body=(bytes(json.dumps(result, indent=2).encode('UTF-8'))))

是Salesforce方面的问题,还是我使用AWS的SDK将对象放入S3时遇到了问题?

Is the problem on the Salesforce side or am I running into an issue using AWS's SDK to put the objects into S3?

推荐答案

Salesforce API会分块返回内容,默认一次是2000条记录.如果返回给您1M记录,则可能会杀死您的内存使用量.检索一个块,进行处理(保存到文件?),请求下一个块.

Salesforce API returns stuff in chunks, default is 2000 records at a time. If it'd return to you 1M records it could kill your memory usage. Retrieve a chunk, process it (save to file?), request next chunk.

直接在项目主页:

sf.query_more("01gD0000002HU6KIAW-2000")
sf.query_more("/services/data/v26.0/query/01gD0000002HU6KIAW-2000", True)
sf.query_all("SELECT Id, Email FROM Contact WHERE LastName = 'Jones'")

这篇关于无法使用Python从Salesforce获取完整记录的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

10-11 08:06