Python3 + beatbox:无法查询更多

时间:2016-11-08 15:43:35

标签: python python-3.x salesforce beatbox

我已使用此处http://tomhayden3.com/2013/08/04/salesforce-python/提供的说明登录了我的SFDC组织。但是,我无法实现queryMore部分。它什么都不做。当我打印(query_locator)时,它打印出一个后缀为-500的ID。有人可以查看这段代码并突出显示我做错了什么吗?

#!/usr/bin/env python3

import beatbox

# Connecting to SFDC
sf = beatbox._tPartnerNS
service = beatbox.Client()
service.serverUrl = 'https://test.salesforce.com/services/Soap/u/38.0'
service.login('my-username', 'my-password')
query_result = service.query("SELECT id, Name, Department FROM User")
records = query_result['records']  # dictionary of results!
total_records = query_result['size']  # full size of results
query_locator = query_result['queryLocator']  # get the mystical queryLocator


# loop through, pulling the next 500 and appending it to your records dict
while query_result['done'] is False and len(records) < total_records:
    query_result = self._service.queryMore(query_locator)
    query_locator = query_result['queryLocator']  # get the updated queryLocator
    records = records + query_result['records']  # append to records dictionary
    print(records['id']) #This should print all IDs??? But it is not.

1 个答案:

答案 0 :(得分:0)

这里的例子为我解决了这个问题。 https://github.com/superfell/Beatbox/blob/master/examples/export.py

INSTALLED VERSIONS
------------------
commit: None
python: 2.7.12.final.0
python-bits: 64
OS: Darwin
OS-release: 15.6.0
machine: x86_64
processor: i386
byteorder: little
LC_ALL: None
LANG: en_US.UTF-8

pandas: 0.18.1