Describing Table Fields with SQLForce

Generally a Python program will know the structure of the Salesforce table being manipulated, but if the table’s structure needs to be discovered at run-time the SQLForce.Session.describeTable() method will provide metadata information.

The SQLForce.Session.describeTable() method returns a list of descriptors for all fields in a specified table, for example:

import SQLForce

session = SQLForce.Session(“myProfile”)

fields = session.describeTable(‘Account’)

for ff in fields:

print(“Field ” + ff.name + ” is of type ” + ff.type )

Available attributes on returned field descriptors include:

Attribute Description
name The API name for the field.
type The data type of the field based on DescribeSobjectResult.Fields.FiledType (see the Salesforce documentation).
label The label displayed in the Salesforce GUI.
length The number of UTF-8 characters allowed.
scale For numbers, the number of digits after the decimal point.
calculated True if the field is a formula.
createable True if the current user can create a record in the corresponding table.
updateable True if the current user can update a record in the corresponding table.