0

I've retrieved the data I need from the 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%')

This returns me an Ordered Dict of records like:

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')])])]))]),

I then convert this to a dataframe:

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'])

This drops the attributes column but within the Backends__r there is still all the other attributes.

How can I remove this and only have AccEmail__c and custid__c to store in a table?

Sam
  • 1,207
  • 4
  • 26
  • 50
  • My Python's too weak but can you try the last query I proposed in https://stackoverflow.com/a/64759652/313628, it should be "flatter" – eyescream Nov 10 '20 at 10:38
  • @eyescream yes this worked thanks. I did add that and had the same issue. But I found how to resolve it here through another post and asked to close this. Thank you for your help – Sam Nov 10 '20 at 10:51
  • Well don't close, post an answer and accept it, i'm sure some poor soul later will happily upvote! – eyescream Nov 10 '20 at 12:03
  • @eyescream true but it's basically the same as this https://stackoverflow.com/questions/47860134/parent-child-relationship-query-in-simple-salesforce-python-extracting-from-ord I just didn't search well enough :/ – Sam Nov 10 '20 at 12:16

0 Answers0