我們可以使用python連接到salesforce並獲取數據的庫或包嗎?python salesforce庫獲取salesforce數據?
9
A
回答
15
我用beatbox
實例來查詢電子郵件地址鉛
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
要獲取其他數據,看看salesforce api docs
查看其他口技例子here
1
這一個是我的經驗中最好的: http://code.google.com/p/salesforce-python-toolkit/
7
還有一個包叫simple_salesforce。
你可以安裝它:
$ pip install simple_salesforce
您可以獲得訪問您的Salesforce帳戶如下:
from simple_salesforce import Salesforce
sf = Salesforce(username='[email protected]', password='password', security_token='token')
自述是關於細節有幫助...
0
雖然這不是Python特定的。我遇到了一個很酷的命令行工具。你可以作爲一個選項運行的bash命令..
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
這裏是準備代碼,讓任何人開始。用於從SFDC獲取報告。
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')
每次更改密碼時,都會收到電子郵件中的salesforce令牌。
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)
相關問題
- 1. 如何從SalesForce數據獲取SalesForce表名
- 2. salesforce數據庫集成
- 3. 獲取salesforce字段的數據類型
- 4. 獲取Salesforce Lead(Python Beatbox SOAP API)的URL
- 5. Salesforce元數據apis
- 6. 使用python導入salesforce報表數據
- 7. 獲得在Salesforce
- 8. SAAS架構和Salesforce數據庫架構
- 9. Salesforce:從Salesforce到Salesforce的SOAP登錄
- 10. Salesforce API:在Salesforce服務器上獲取時間
- 11. 如何使用django-salesforce獲取Salesforce附件文件內容?
- 12. python salesforce beatbox:beatbox._beatbox.SoapFaultError:'INVALID_FIELD'
- 13. Salesforce Rest Request,插入數據
- 14. 從salesforce中檢索數據
- 15. Salesforce檢索對象數據
- 16. Ruby:獲得salesforce oauth_token
- 17. Salesforce數據庫集成(維護集中式數據庫)
- 18. 無法從Salesforce獲取聯繫人
- 19. Salesforce web2lead表單不發送數據給salesforce
- 20. 獲取加密錯誤而分析數據從Salesforce
- 21. 獲取Salesforce自定義字段值
- 22. Salesforce Visualforce獲取CreatedBy字段標籤
- 23. 未知的URL獲取插入在Salesforce
- 24. Salesforce從聯繫人獲取MailingAddress
- 25. 認證後從Salesforce獲取照片
- 26. (400)Bad Request:獲取Salesforce的AccessToken
- 27. MuleESB:將Salesforce數據插入到mysql數據庫中
- 28. Salesforce Apex
- 29. 在Salesforce
- 30. Salesforce JavaScript
嘿matto,我看到他們的下載,是否只爲Windows?沒有包的Linux/MAC? – daydreamer
如果你安裝了setuptools你可以做'easy_install beatbox',否則從github https://github.com/superfell/Beatbox下載包並運行'python setup.py install' – MattoTodd
真棒,會試試 – daydreamer