2011-09-21 13 views
9

क्या कोई पुस्तकालय या पैकेज है जिसे हम बिक्री बल से कनेक्ट करने और डेटा प्राप्त करने के लिए पाइथन के साथ उपयोग कर सकते हैं?पायथन बिक्री बल पुस्तकालय बिक्री बल डेटा प्राप्त करने के लिए?

उत्तर

15

मैं ईमेल पते से एक का नेतृत्व

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 

अन्य डेटा प्राप्त करने के लिए के लिए क्वेरी करने के लिए beatbox

उदाहरण का उपयोग अन्य बीटबॉक्स उदाहरण here

+0

हे मैटो, मैंने उनके डाउनलोड देखा, क्या यह केवल विंडोज के लिए है? लिनक्स/मैक के लिए कोई पैकेज नहीं है? – daydreamer

+0

यदि आपके पास setuptools इंस्टॉल है, तो आप 'easy_install beatbox' कर सकते हैं, अन्यथा github https://github.com/superfell/Beatbox से पैकेज डाउनलोड करें और' python setup.py install' – MattoTodd

+0

भयानक चलाएं, – daydreamer

7

simple_salesforce नामक एक पैकेज भी है।

आप के साथ स्थापित कर सकते हैं:

$ pip install simple_salesforce 

आप के साथ अपने Salesforce के खाते में पहुँच प्राप्त कर सकते हैं निम्नलिखित:

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

रीडमी विवरण के संबंध में उपयोगी है ...

0

हालांकि यह पायथन विशिष्ट नहीं है। मैं कमांड लाइन के लिए एक शांत उपकरण में आया था। आप .. एक विकल्प के रूप बैश कमांड चलाने सकता

https://force-cli.heroku.com/

Usage: force <command> [<args>] 

Available commands: 
    login  force login [-i=<instance>] [<-u=username> <-p=password>] 
    logout Log out from force.com 
    logins List force.com logins used 
    active Show or set the active force.com account 
    whoami Show information about the active account 
    describe Describe the object or list of available objects 
    sobject Manage standard & custom objects 
    bigobject Manage big objects 
    field  Manage sobject fields 
    record Create, modify, or view records 
    bulk  Load csv file use Bulk API 
    fetch  Export specified artifact(s) to a local directory 
    import Import metadata from a local directory 
    export Export metadata to a local directory 
    query  Execute a SOQL statement 
    apex  Execute anonymous Apex code 
    trace  Manage trace flags 
    log  Fetch debug logs 
    eventlogfile List and fetch event log file 
    oauth  Manage ConnectedApp credentials 
    test  Run apex tests 
    security Displays the OLS and FLS for a give SObject 
    version Display current version 
    update Update to the latest version 
    push  Deploy artifact from a local directory 
    aura  force aura push -resourcepath=<filepath> 
    password See password status or reset password 
    notify Should notifications be used 
    limits Display current limits 
    help  Show this help 
    datapipe Manage DataPipes 
2

यहाँ किसी को आरंभ करने के लिए तैयार कोड है। एसएफडीसी से रिपोर्ट लाने के लिए।

import pandas as pd 
import numpy as np 
from pandas import DataFrame, Series 
from simple_salesforce import Salesforce #imported salesforce 
sf = Salesforce(username='[email protected]', password='enter_password', security_token = 'Salesforce_token') 

बिक्री बल टोकन हर बार जब आप अपना पासवर्ड बदलते हैं तो ईमेल में प्राप्त होता है।

import requests #imported requests 
session = requests.Session() #starting sessions 
from io import StringIO #to read web data 
error_report_defined = session.get("https://na4.salesforce.com/xxxxxxxxxxxx?export=1&enc=UTF-8&xf=csv".format('xxxxxxxxxxxx'), headers=sf.headers, cookies={'sid': sf.session_id}) 
df_sfdc_error_report_defined = pd.DataFrame.from_csv(StringIO(error_report_defined.text)) 
df_sfdc_error_report_defined = df_sfdc_error_report_defined.to_csv('defined.csv', encoding = 'utf-8') 
error_report = pd.read_csv('defined.csv') #your report is saved in csv format 
print (error_report) 
संबंधित मुद्दे