//How to Connect to Salesforce Using SQLForce
How to Connect to Salesforce Using SQLForce 2018-03-26T14:19:41+00:00

How to Connect to Salesforce Using SQLForce

Opening a SQLForce connection to Salesforce uses one of two patterns:

  • session = SQLForce.Session(“type”, “username”, “password”, [,”token”] [, proxyHost=”host:port” [, proxyUser=”user”, proxyPassword=”password”]])
  • session = SQLForce.Session(“ProfileName”)

The first form includes Salesforce credentials as part of the call, the second form looks up credentials in an external file.

In both cases, up to four parameters are required to establish a Salesforce session:

Parameter Required Description
 type Yes The type of Salesforce instance to connect to. Supported values are:

  • Production
  • Sandbox
  • DatabaseDotCom
username Yes Salesforce username to authenticate with. If the Salesforce type is Sandbox, remember to append the sandbox name.

If you use a custom domain your login host will not match one of the standard Salesforce domains. In this case, prepend your username with the name of your login host. For example:

  • capstorm.my.salesforce.com:greg@capstorm.com
password Yes Salesforce password to authenticate with.
token If Needed By Salesforce Security token required by Salesforce when connecting through the API. This value is required if your Salesforce instance mandates the use of security tokens.
proxyHost No Hostname and port used for Salesforce connections when connecting through a proxy. Examples:

  • 172.16.10.10:8013
  • myproxy.myco.com:7834
proxyUser No Username used to authenticate with the proxy. This parameter is only needed if your proxy requires authentication.
proxyPassword No Password used to authenticate with the proxy. This parameter is only needed if your proxy requires authentication.

Embedded Credentials

The simplest way to connect to Salesforce is to include Salesforce credentials in the call to SQLForce.session(). The basic form of a Session() call is:

  • session = SQLForce.Session(“type”, “username”, “password” [, “token”])

For example:

External Credentials

SQLForce credentials can be stored in a file named “$HOME/sqlforce.ini”, and can be referenced as part of a SQLForce.Session() call. This is a common approach to avoid embedding credentials in Python scripts. A typical sqlforce.ini file is included below — the additional parameter, name, is the value used to create a Salesforce connection in SQLForce:

  • session = SQLForce.Session(“productionMain”)
<sqlforce>

    <connection
    name="productionMain"
    type="production"
    username="capstorm.my.salesforce.com:admin@capstorm.com"
    password="ProductionPassword"
    />

    <connection
    name="UnitTests"
    type="sandbox"
    username="capstormsoftware@gmail.com"
    password="SandboxPassword"
    />

    <connection
    name="ProxyConnection"
    type="Production"
    username="capstormsoftware@gmail.com"
    password="myPassword"
    proxyHost="proxy.capstormdev.com:8888"

</sqlforce>

CONTACTS

Product Questions: info@capstorm.com
Technical Support: support@capstorm.com
Phone: +1 314.403.2143