我从 Salesforce API 中检索到了我需要的数据:
SELECT AccEmail__c,
(select custid__c from Backends__r)
from Account
where Id in (select account__c from Backend__c where custid__c LIKE '%CUST%')
这会返回一个 Ordered Dict 记录,例如:
Out[22]: {'records': [OrderedDict([('attributes',
OrderedDict([('type', 'Account'),
('url',
'/services/data/')])),
('AccEmail__c', 'email.com'),
('Backends__r',
OrderedDict([('totalSize', 1),
('done', True),
('records',
[OrderedDict([('attributes',
OrderedDict([('type',
'Backend__c'),
('url',
'/services/data/')])),
('custid__c',
'CUST209522')])])]))]),
然后我将其转换为数据框:
a_query= pd.DataFrame(sf.query_all("SELECT AccEmail__c, (select custid__c from Backends__r where custid__c LIKE '%CUST%') from Account where Id in (select account__c from Backend__c where custid__c LIKE '%CUST%')")['records']).drop(columns=['attributes'])
这会删除属性列,但在 Backends__r 中仍然存在所有其他属性。
如何删除它并且只有 AccEmail__c 和 custid__c 存储在表中?