标题:使用 simple_salesforce Library 的 upsert 方法延长响应时间

Title: Extended Response Time with simple_salesforce Library's upsert method

提问人:Mahesh Patil 提问时间:11/16/2023 更新时间:11/16/2023 访问量:12

问:

问题陈述:

我在使用 simple_salesforce 库使用批量功能批量执行更新插入操作时遇到超过 30 秒的延长响应时间。upsert 方法似乎需要更长的处理时间,从而影响了我的应用程序的整体性能。

from simple_salesforce import Salesforce
import requests
import json

# Salesforce credentials
USERNAME = 'xxx'
PASSWORD = 'yyy'
CLIENT_ID = 'zzzzzzzzz'
CLIENT_SECRET = 'a1b1c1'
token_url = ''



payload = {
            'grant_type': 'password',
            'client_id': CLIENT_ID,
            'client_secret': CLIENT_SECRET,
            'username': USERNAME,
            'password': PASSWORD
        }
try:
    print('Invoking token endpoint')
    r = requests.post(
        token_url,
        headers={"Content-Type":"application/x-www-form-urlencoded"}, data=payload)

    body = r.json()
    token = body['access_token']
    print("session Id:",token)
    
    sf = Salesforce(instance_url=instance_url, session_id=token)   
    

    data = "[{"id": "1de4f46gfdvznasdsa","name": "Test-1"},{"id": "1gfsdvznasdsw324a1","name": "Test-2"},{"id": "46gfdvznasdsa2eref23","name": "Test-3"}]"
    response = sf.bulk.Account.upsert(data, 'Account')
    print("Response= ",response)   
        
    
        
except requests.exceptions.RequestException as e:
    print("Error in request:", str(e))
    
except Exception as e:
    print('Error: ', str(e))
                    

环境详细信息: Python版本:3.10 simple_salesforce库版本:1.12.5

所做的努力:

1. I tried to optimize code using bulk query and operater but getting same response.
2. I tried with request package and working fine using api response time is appropriate

但是我想知道为什么在使用 simple-salesforce 模块时需要长时间响应。

请求:

我正在寻求有关优化更新插入过程的指导或建议,以提高使用 simple_salesforce 库进行批量操作时的性能。

感谢您的任何见解或帮助。

python fastapi simple-salesforce

评论


答: 暂无答案