Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

python salesforce library to get salesforce data?

Is there a library or package which we can use with python to connect to salesforce and get data?

like image 265
daydreamer Avatar asked Sep 21 '11 17:09

daydreamer


2 Answers

There's also a package called simple_salesforce .

You can install it with:

$ pip install simple_salesforce

You can gain access to your Salesforce account with the following:

from simple_salesforce import Salesforce
sf = Salesforce(username='[email protected]', password='password', security_token='token')

The readme is helpful with regards to details...

like image 61
Kat Avatar answered Sep 19 '22 19:09

Kat


I use beatbox

Example to query for a lead by email address

import beatbox
sf_username = "Username"
sf_password = "password"
sf_api_token = "api token"    

def get_lead_records_by_email(email)
    sf_client = beatbox.PythonClient()
    password = str("%s%s" % (sf_password, sf_api_token))
    sf_client.login(sf_username, password)
    lead_qry = "SELECT id, Email, FirstName, LastName, OwnerId FROM Lead WHERE Email = '%s'" % (email)
    records = sf_client.query(lead_qry)
    return records

To get other data look at the salesforce api docs

view other beatbox examples here

like image 44
MattoTodd Avatar answered Sep 17 '22 19:09

MattoTodd