,可以通过以下步骤实现:
from simple_salesforce import Salesforce
sf = Salesforce(username='your_username', password='your_password', security_token='your_security_token')
请将"your_username"替换为Salesforce账号的用户名,"your_password"替换为密码,"your_security_token"替换为安全令牌。
query = "SELECT field1, field2 FROM ObjectName WHERE field3 = '{}'".format(variable)
请将"field1, field2"替换为需要查询的字段,"ObjectName"替换为对象名称,"field3"替换为需要匹配的字段,"variable"替换为传递的变量。
result = sf.query_all(query)
完整的示例代码如下:
from simple_salesforce import Salesforce
sf = Salesforce(username='your_username', password='your_password', security_token='your_security_token')
variable = 'example'
query = "SELECT field1, field2 FROM ObjectName WHERE field3 = '{}'".format(variable)
result = sf.query_all(query)
这样,你就可以使用python和simple-salesforce在SOQL select语句中传递变量进行查询了。
领取专属 10元无门槛券
手把手带您无忧上云