{ "cells": [ { "cell_type": "markdown", "metadata": {}, "source": [ "# Example usage\n", "\n", "To use `salesforce_tools` in a project:" ] }, { "cell_type": "code", "execution_count": 1, "metadata": {}, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "0.1.0\n" ] } ], "source": [ "import salesforce_tools\n", "from salesforce_tools.salesforce_tools import SalesforceTools\n", "import os\n", "\n", "print(salesforce_tools.__version__)" ] }, { "cell_type": "code", "execution_count": 5, "metadata": {}, "outputs": [], "source": [ "# Authenticate with your credentials\n", "user = 'crastello.py@gmail.com'\n", "pw = os.environ.get('SFDC_PASS')\n", "token = os.environ.get('SFDC_TOKEN')\n", "\n", "sf = SalesforceTools(username=user,password=pw,security_token=token)" ] }, { "cell_type": "code", "execution_count": 6, "metadata": {}, "outputs": [], "source": [ "### Run a SOQL Query and return result as a df\n", "\n", "soql = '''SELECT Id, Name, CloseDate, CreatedDate FROM Opportunity LIMIT 5'''\n", "\n", "opps = sf.sf_api_query(soql=soql, dateList=['CloseDate','CreatedDate'],tz='America/Chicago')" ] }, { "cell_type": "code", "execution_count": 7, "metadata": {}, "outputs": [ { "data": { "text/html": [ "
\n", "\n", "\n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", "
IdNameCloseDateCreatedDate
0006a50000004MBeAAMOpportunity for Conner52024-08-282024-02-10 02:26:48
1006a50000004MBfAAMOpportunity for Chandler1332024-06-062024-02-10 02:26:48
2006a50000004MBjAAMOpportunity for McDonald132024-01-102024-02-10 02:26:48
3006a50000004MBkAAMOpportunity for Jefferson172023-09-192024-02-10 02:26:48
4006a50000004MBlAAMOpportunity for McLaughlin1302024-03-182024-02-10 02:26:48
\n", "
" ], "text/plain": [ " Id Name CloseDate \\\n", "0 006a50000004MBeAAM Opportunity for Conner5 2024-08-28 \n", "1 006a50000004MBfAAM Opportunity for Chandler133 2024-06-06 \n", "2 006a50000004MBjAAM Opportunity for McDonald13 2024-01-10 \n", "3 006a50000004MBkAAM Opportunity for Jefferson17 2023-09-19 \n", "4 006a50000004MBlAAM Opportunity for McLaughlin130 2024-03-18 \n", "\n", " CreatedDate \n", "0 2024-02-10 02:26:48 \n", "1 2024-02-10 02:26:48 \n", "2 2024-02-10 02:26:48 \n", "3 2024-02-10 02:26:48 \n", "4 2024-02-10 02:26:48 " ] }, "execution_count": 7, "metadata": {}, "output_type": "execute_result" } ], "source": [ "opps.head()" ] } ], "metadata": { "kernelspec": { "display_name": "penv_3_11", "language": "python", "name": "python3" }, "language_info": { "codemirror_mode": { "name": "ipython", "version": 3 }, "file_extension": ".py", "mimetype": "text/x-python", "name": "python", "nbconvert_exporter": "python", "pygments_lexer": "ipython3", "version": "3.11.10" } }, "nbformat": 4, "nbformat_minor": 4 }