simple-salesforce | A very simple Salesforce.com REST API client for Python | REST library

 by   simple-salesforce Python Version: 1.12.6 License: Non-SPDX

kandi X-RAY | simple-salesforce Summary

kandi X-RAY | simple-salesforce Summary

simple-salesforce is a Python library typically used in Web Services, REST applications. simple-salesforce has no bugs, it has no vulnerabilities, it has build file available and it has high support. However simple-salesforce has a Non-SPDX License. You can install using 'pip install simple-salesforce' or download it from GitHub, PyPI.

A very simple Salesforce.com REST API client for Python
Support
    Quality
      Security
        License
          Reuse

            kandi-support Support

              simple-salesforce has a highly active ecosystem.
              It has 1437 star(s) with 624 fork(s). There are 91 watchers for this library.
              There were 1 major release(s) in the last 12 months.
              There are 140 open issues and 245 have been closed. On average issues are closed in 67 days. There are 32 open pull requests and 0 closed requests.
              OutlinedDot
              It has a negative sentiment in the developer community.
              The latest version of simple-salesforce is 1.12.6

            kandi-Quality Quality

              simple-salesforce has 0 bugs and 22 code smells.

            kandi-Security Security

              simple-salesforce has no vulnerabilities reported, and its dependent libraries have no vulnerabilities reported.
              simple-salesforce code analysis shows 0 unresolved vulnerabilities.
              There are 11 security hotspots that need review.

            kandi-License License

              simple-salesforce has a Non-SPDX License.
              Non-SPDX licenses can be open source with a non SPDX compliant license, or non open source licenses, and you need to review them closely before use.

            kandi-Reuse Reuse

              simple-salesforce releases are available to install and integrate.
              Deployable package is available in PyPI.
              Build file is available. You can build the component from source.
              simple-salesforce saves you 867 person hours of effort in developing the same functionality from scratch.
              It has 1985 lines of code, 146 functions and 15 files.
              It has medium code complexity. Code complexity directly impacts maintainability of the code.

            Top functions reviewed by kandi - BETA

            kandi has reviewed simple-salesforce and discovered the below as its top functions. This is intended to give you an instant insight into simple-salesforce implemented functionality, and help decide if they suit your requirements.
            • Login to Salesforce .
            • Checks the deployment status .
            • Bulk operation .
            • Login to a user .
            • Queries the Salesforce API .
            • Initialize the session .
            • Quote a SOQL value .
            • Login to a portal .
            • Get a specific customer id
            • Fetches metadata for the specified collection .
            Get all kandi verified functions for this library.

            simple-salesforce Key Features

            No Key Features are available at this moment for simple-salesforce.

            simple-salesforce Examples and Code Snippets

            Using simple salesforce to get field names for each salesforce object in a loop
            Pythondot img1Lines of Code : 4dot img1License : Strong Copyleft (CC BY-SA 4.0)
            copy iconCopy
            api_names = ["Account", "Contact", "Campaign"]
            for obj in Api_names:
                desc = getattr(sf, obj).describe()
            
            Saleforce retrieving fields from two different objects - (SOQL) Simple Salesforce Python
            Pythondot img2Lines of Code : 14dot img2License : Strong Copyleft (CC BY-SA 4.0)
            copy iconCopy
            SELECT AccEmail__c,
                (select custid__c from Backends__r)
            from Account 
            where Id in (select account__c from Backend__c where custid__c LIKE '%CUST%')
            
            SELECT AccEmail__c,
                (select custid__c from Backends__r whe
            query a list of ids in Python via simple-salesforce
            Pythondot img3Lines of Code : 5dot img3License : Strong Copyleft (CC BY-SA 4.0)
            copy iconCopy
            task_result = sf.query(format_soql(
                "SELECT Id, WhoId FROM Task WHERE Id = {task_id}", 
                task_id=task_id))
                
            
            How can I filter a SOQL query in a Python script after a specific datetime?
            Pythondot img4Lines of Code : 10dot img4License : Strong Copyleft (CC BY-SA 4.0)
            copy iconCopy
            max_date = '2020-08-10T17:41:29' # in prod, pull this data from BigQuery
            max_date = max_date + "Z"
            
            SF_QUERY = ("""
              SELECT Id,
              CreatedDate
              FROM Opportunity
              WHERE CreatedDate > %s
              """ % max_date)
            
            ModuleNotFoundError: No module named 'simple_salesforce'
            Pythondot img5Lines of Code : 2dot img5License : Strong Copyleft (CC BY-SA 4.0)
            copy iconCopy
            pip install simple-salesforce
            
            Error on authentication while trying to hit Salesforce API for test org
            Pythondot img6Lines of Code : 7dot img6License : Strong Copyleft (CC BY-SA 4.0)
            copy iconCopy
            
                Sforce SOAP API
                
                    
                
            
            
            Method not working with SFType in a class
            Pythondot img7Lines of Code : 5dot img7License : Strong Copyleft (CC BY-SA 4.0)
            copy iconCopy
            df = SFType(self.obj, self.sf.session_id, self.sf.sf_instance)
            data = df.describe()
            columns = [x['name'] for x in data['fields']]
            return columns
            
            How to write a for loop to dynamically call values in a function?
            Pythondot img8Lines of Code : 46dot img8License : Strong Copyleft (CC BY-SA 4.0)
            copy iconCopy
            object_to_export = ['Opportunity','Asset']
            
            
            def sf_login():
                """
                Purpose: This function is designed to validate your Salesforce credentials and 
            create/return an instance or session.
                Note: If we have already signed in, this wil
            passing a variable in SOQL select statement with python and simple-salesforce
            Pythondot img9Lines of Code : 5dot img9License : Strong Copyleft (CC BY-SA 4.0)
            copy iconCopy
            import datetime
            yesterday = datetime.datetime.now() + datetime.timedelta(days=-1)
            sf_data = sf.query_all("SELECT ID, Name FROM Opportunity where probability > 0 AND CreatedDate > '%s' AND AdPoint_Id__c <> NULL ORDER BY AdPoint_
            How to get the tabs information in a salesforce account using REST API in python?
            Pythondot img10Lines of Code : 2dot img10License : Strong Copyleft (CC BY-SA 4.0)
            copy iconCopy
            SELECT name, Email FROM Contact WHERE LastName = 'Chen'
            

            Community Discussions

            QUESTION

            Salesforce MFA in simple-salesforce
            Asked 2021-Jun-05 at 04:04

            I am currently using the simple-salesforce library to retrieve data from Salesforce, using the token method.

            ...

            ANSWER

            Answered 2021-Apr-22 at 19:51

            I think MFA will be required only for users using the standard login - from the Help article mentioned above, it says: "All internal users who log in to Salesforce products* (including partner solutions) through the user interface must use MFA. To ensure that MFA is enabled for all your Salesforce users, you can turn it on directly in your Salesforce products or use your SSO provider's MFA service."

            But you are auth'ing via the API, right?

            Can you share an error message or screenshot?

            Typically API auths happen via a connected app configured in the org, and as I recall, the connected app has a setting requiring MFA ... This help article goes into greater detail about where MFA is required (which login approaches)

            Could it be that you are running into the standard user verification challenge whenever salesforce sees an auth for a user from a new network location. You can disable that here by setting an IP address range.

            Source https://stackoverflow.com/questions/67097311

            QUESTION

            simple-salesforce bulk upsert not working as expected
            Asked 2020-Oct-24 at 16:11

            I am trying to bulk upsert records into Salesforce using the simple-salesforce Python library.

            I have a list of dictionaries called categories with the format [{'FooNumber': '001', 'Category': 'A'}, {'FooNumber': '002', 'Category': 'B'}, {'FooNumber': '003', 'Category': 'C'}...]

            When I try upsert with one record at a time it works:

            sf.Foo.upsert('FooNumber/001', {'Category': 'A'})

            According to the documentation, the following bulk upsert code should work:

            sf.bulk.Foo.upsert(scores, 'FooNumber', batch_size=1000)

            But, I get the following error:

            TypeError: upsert() got an unexpected keyword argument 'batch_size'

            What is wrong with bulk upsert?

            Note: I cannot make the code reproducible since I am working with private data.

            ...

            ANSWER

            Answered 2020-Oct-24 at 16:11

            Most likely, you need to update your simple_salesforce. This capability was added in simple_salesforce 1.1.0, the latest release.

            Source https://stackoverflow.com/questions/64430191

            QUESTION

            How can I filter a SOQL query in a Python script after a specific datetime?
            Asked 2020-Aug-12 at 17:13

            I'm trying to select all records from the OPPORTUNITY object that are greater than a variable DateTime. However, I can't figure out how. This is in a Python script using the simple_salesforce package. I believe the issue is either that I am missing the millisecond and +0000 timezone specification in my "max_date" parameter, which I retrieve from a BigQuery table, or that I'm not passing in my max_date parameter as a correct datatype.

            My example code that does not work:

            ...

            ANSWER

            Answered 2020-Aug-12 at 17:13

            The solution is to append a "Z", short for Zulu time, which indicates UTC, to the end of my datetime string. The dynamic variable %s should not have quotes. Example:

            Source https://stackoverflow.com/questions/63380604

            QUESTION

            How do I access the Salesforce API when single-sign on is enabled?
            Asked 2020-Jun-24 at 23:11

            I'm attempting to make SOQL queries to the Salesforce API using the Python salesforce_api and simple-salesforce modules. I had been making these requests with a client object:

            ...

            ANSWER

            Answered 2020-Jun-24 at 23:11

            Uh. It's doable but it's an art. I'll try to write it up but you should have a look at "Identity and Access Management" Salesforce certification, study guides etc. Try also asking at salesforce.stackexchange.com, might get better answers and Okta specialists.

            I don't know if there's pure server-side access to Okta where you'd provide OAuth2 client, secret, username and password and it'd be silently passed to login.

            If your app is a proper web application that needs human to operate - you can still make it work with SSO. You'd have to read about OAuth2 in general (you saw it on the web, all the "login with Google/Facebook/LinkedIn/Twitter/..." buttons) and then implement something like this or this. Human starts in your app, gets redirected to SF to enter username and password (you don't see password and you don't care whether he encountered normal SF login page or some SSO), on success he/she is redirected back and you receive info that'll let you obtain session id (sometimes called access token). Once you have access token you can make queries etc, it's just a matter of passing it as HTPP Authorization Bearer header (simple-salesforce docs mention session id at top of the examples).

            Look, I know what I've written doesn't make much sense. Download Data Loader and try to use it. You might have to make it use custom domain on login but there is a way for it to still work, even though you have SSO enforced. Your goal would be to build similar app to how Data Loader does it. This might help a bit: https://stackoverflow.com/a/61820476/313628

            If you need a true backend integration without human involved... tricky. That might be a management problem though. They should not enforce SSO on everybody. When Okta's down you're locked out of the org, no way to disable SSO. You should have a backup plan, some service account(s) that don't have SSO enforced. They might have crazy password requirements, maybe login only from office IP address, whatever. It's not a good idea to enforce SSO on everybody.

            https://help.salesforce.com/articleView?id=sso_tips.htm

            We recommend that you don’t enable SSO for Salesforce admins. If your Salesforce admins are SSO users and your SSO server has an outage, they have no way to log in to Salesforce. Make sure that Salesforce admins can log in to Salesforce so that they can disable SSO if problems occur.

            (If you have a web app and it's embedded as Canvas in SF - there's another clean way to have the session id passed to you. Again - this works only if you have a human rather than backend integration)

            Source https://stackoverflow.com/questions/62563315

            QUESTION

            Can't Import psycopg2._psycopg Inside a docker
            Asked 2020-Apr-29 at 22:20

            I am trying to build a docker image with the following requirement.txt file but when I call my python function, there is a part that calls to a redshift database to perform query and ectract data, then I get an error :

            ImportError: /usr/local/lib/python2.7/site-packages/psycopg2/.libs/libresolv-2-c4c53def.5.so: symbol __res_maybe_init version GLIBC_PRIVATE not defined in file libc.so.6 with link time reference

            ...

            ANSWER

            Answered 2020-Apr-29 at 22:20

            You should update psycopg2 to atleast 2.7.3.1 avoid compatibility issues with glibc 2.26

            from release notes

            Dropped libresolv from wheel package to avoid incompatibility with glibc 2.26 (wheels ticket #2).

            Source https://stackoverflow.com/questions/61512615

            QUESTION

            Cannot login to Salesforce Sandbox via python API
            Asked 2020-Feb-28 at 22:30

            I am using the python3.7.2 module simple-salesforce==0.74.2 and I am having trouble trying to establish a connection to my salesforce sandbox. I can login to the salesforce production with the same credentials just fine like so:

            ...

            ANSWER

            Answered 2019-Apr-11 at 17:53

            Solved. Set domain='test' and generate a new token under your sandbox account

            Source https://stackoverflow.com/questions/55637419

            QUESTION

            SOQL: Is there a way to return column headers even if zero rows meet the query
            Asked 2020-Feb-11 at 22:25

            I'm currently using simple-salesforce to return some rows and write to a csv file with column headers. However, if the row count is 0 e.g. 'select Id from Lead limit 0' I just get the following response

            OrderedDict([('totalSize', 0), ('done', True), ('records', [])])

            Is there a way of still getting the column headers even if there are zero rows returned in the query.

            Basically I need to create the csv with headers even if there are 0 rows

            ...

            ANSWER

            Answered 2020-Feb-11 at 22:25

            Unfortunately, there's not. A query doesn't really return headers as such at all (unless you use the Bulk API); in just returns a list of records composed of key-value pairs.

            The usual pattern is that you generate a query from a list of fields, and that list of fields becomes your column headers. For example,

            Source https://stackoverflow.com/questions/60167091

            QUESTION

            How to perform a JOIN in Salesforce (SOQL) - Simple Salesforce (Python Library)
            Asked 2020-Jan-29 at 13:54

            I am using simpleSalesforce library for python to query SalesForce.

            I am looking at two different object in SalesForce: Account and Opportunity (parent-child). There is an accountId inside the opportunity object.

            I am trying to perform an inner join between the two and select the results (fields from both objects). a normal SQL statement would look like this:

            ...

            ANSWER

            Answered 2020-Jan-29 at 13:54

            A couple notes about SOQL:

            • No aliases allowed
            • No explicit joins allowed

            But with that in mind, it's still possible to get the outcome you want by directly using the desired fields names as an "attribute" of the object relationship. Example:

            SELECT account.Name, Name, StageName FROM Opportunity

            Which will grab the related account name, the opportunity name, and the opportunity stage name in one query.

            As long as the field on your base object is of a type Lookup or Master-Detail, you can use this type of relationship. In the case of custom fields, you switch the __c over to __r though.

            Example: Opportunity has a relationship to custom object Address__c and we want to know what city & country these opportunities are in:

            SELECT Address__r.Country__c, Address__r.City__c,Name, StageName from Opportunity

            Source https://stackoverflow.com/questions/59645496

            QUESTION

            How do I remove ALL email files using os.remove() ? Email to TFS ticket
            Asked 2020-Jan-16 at 15:55

            We currently use TFS as ticket system for Support Tickets. I wrote the code below so that a user can dump an email into a folder and then access a webpage to submit a form and create a TFS Support Ticket and assign it to the user. The goal is to have the emails removed from the folder after the form has been submitted and the Support Ticket has been created.

            The problem I'm running into is that when I try to remove the emails after the TFS Support Ticket has been created it removes some of the files but then gets stuck on the last one and display the following error message.

            "PermissionError: [WinError 32] The process cannot access the file because it is being used by another process: 'C:\Users\b4bw3\Documents\Python\simple-salesforce\Email\Delete_Me1.msg'"

            If I remove the portion of code that creates the TFS ticket then it will rename the email and remove it after it is done as expected. It appears that the hang up is with TFS. I'm stumped and need help.

            Any thoughts? btw, this is my first attempt at Python, so be gentle. :)

            '''

            ...

            ANSWER

            Answered 2020-Jan-16 at 15:55

            It appears this is a current bug for the msg-extractor. I found the link below that explains in detail.

            https://github.com/mattgwwalker/msg-extractor/issues/85?_pjax=%23js-repo-pjax-container

            I added the following code line to the end of my method and it works like a charm.

            Source https://stackoverflow.com/questions/59740319

            QUESTION

            Format a string into Date or any other datatype in Django
            Asked 2019-Dec-14 at 21:17

            I am using Python 3.6 with Django 1.11. My Back-end DB is Salesforce.

            I am trying to save date field in Salesforce which is accepted from user in the form of String

            ...

            ANSWER

            Answered 2017-Nov-09 at 09:56

            According to this link, one should pass dates as UTC datetime, so:

            Source https://stackoverflow.com/questions/47195630

            Community Discussions, Code Snippets contain sources that include Stack Exchange Network

            Vulnerabilities

            No vulnerabilities reported

            Install simple-salesforce

            You can install using 'pip install simple-salesforce' or download it from GitHub, PyPI.
            You can use simple-salesforce like any standard Python library. You will need to make sure that you have a development environment consisting of a Python distribution including header files, a compiler, pip, and git installed. Make sure that your pip, setuptools, and wheel are up to date. When using pip it is generally recommended to install packages in a virtual environment to avoid changes to the system.

            Support

            For any new features, suggestions and bugs create an issue on GitHub. If you have any questions check and ask questions on community page Stack Overflow .
            Find more information at:

            Find, review, and download reusable Libraries, Code Snippets, Cloud APIs from over 650 million Knowledge Items

            Find more libraries
            Install
          • PyPI

            pip install simple-salesforce

          • CLONE
          • HTTPS

            https://github.com/simple-salesforce/simple-salesforce.git

          • CLI

            gh repo clone simple-salesforce/simple-salesforce

          • sshUrl

            git@github.com:simple-salesforce/simple-salesforce.git

          • Stay Updated

            Subscribe to our newsletter for trending solutions and developer bootcamps

            Agree to Sign up and Terms & Conditions

            Share this Page

            share link