It's All Writing.

Writing makes you happy.

How to get Salesforce sObject's fields information by python

It's simple. You can use simple_salesforce for this purpose. The describe method returns sObject's meta data. The environment and code is below.


  • python 3.6.x
  • simple_salesforce



from simple_salesforce import Salesforce

fields = get_fields('Account')
# => ['Id', 'IsDeleted', 'MasterRecordId', 'Name', .... ]

def get_fields(sObject):
    sf = Salesforce(username='your_username', password='your_password', security_token='your_security_token')

    desc = eval('sf.{}.describe()'.format(sObject))
    fields = [field['name'] for field in desc['fields']]

    return fields