专栏首页CRM日记本Salesforce的Data Loader命令行-解决常见错误

Salesforce的Data Loader命令行-解决常见错误

Data Loader是一个Salesforce提供的本地工具可以用来insert, upsert, update,导出和删除数据。

标准Data Loader使用向导需要我们手动操作这些命令。然而在很多的场景中,我们需要反复执行这些数据加载任务,例如每天晚上凌晨一点(夜间服务)来运行某些操作。因此,对于这些情况我们可以使用标准的Data Loader命令行工具来解决。

在本文中,我将会详细介绍如何使用Data Loader命令行

在Data loader中建立命令行的最重要的部分就是利用DataLoader提供的功能来生成加密密码。

Commandline Data Loader tools

这个目录包含两个应用程序批处理文件:“encrypt.bat“和“process.bat”

运行CMD,将命令行导航到“Program Files | Data Loader | bin”并运行命令。

encrypt.bat –g YOURSECRETKEY

Generate Secret Key for Command Line Dataloader

私有密钥是根据你输入的信息自动生成的。复制突出白色显示的文本并粘贴在新文本文件“Key.txt”。

现在再次运行上面的命令生成加密密码

encrypt.bat -e password "C:Users\shiva\Desktop\Data Loader Documents\Try\Key.txt"

Commandline Data Loader generate Encrypted Password

现在,注意这个密码,因为我们将用它来配置剩下的部分

用下面的命令确认密码是否正确:

encrypt.bat -v generatedPassword secretKey

如果您使用代理服务器,,可重复相同步骤生成加密的密码。

创建文件-“config.properties”:

这个文件包含所有常见的设置像用户名,加密的密码的等。这个文件也可以空白,不过最好将常见的配置都写在此文件里。Keys在这个文件将和结尾描述的“Process-config.xml”类似。下面是例子:

#Loader Config
#Wed Sep 19 2012
sfdc.debugMessages=true
process.encryptionKeyFile=C:\Users\shiva\Desktop\Data Loader Documents\Try\Key.txt
sfdc.debugMessagesFile = C:\Users\shiva\Desktop\Data Loader Documents\Try\AccountExport.log
sfdc.endpoint=https://login.salesforce.com
sfdc.username=ilovenagpur@gmail.com
sfdc.password=7b5693f0cad856dc778d4b8506f2c976
sfdc.proxyUsername=proxyUserName
sfdc.proxyPassword=encrypytesPassword
sfdc.proxyHost=proxyhostName
sfdc.proxyPort=123
sfdc.loadBatchSize=200
sfdc.timeoutSecs=600

创建文件-“process-conf.xml”

该文件包含导入导出的所有信息。在这里我们导入客户数据,所以该文件是:

<!DOCTYPE beans PUBLIC "-//SPRING//DTD BEAN//EN" "http://www.springframework.org/dtd/spring-beans.dtd">
<beans>
<bean id="Account"
    class="com.salesforce.dataloader.process.ProcessRunner"
    singleton="false">
        <description>Export Account Data</description>
        <property name="name" value="Account"/>
        <property name="configOverrideMap">
        <map>
            <entry key="sfdc.enableLastRunOutput" value="false"/>
            <entry key="sfdc.entity" value="Account"/>
            <entry key="process.operation" value="extract"/>
            <entry key="sfdc.extractionRequestSize" value="500"/>
            <entry key="sfdc.extractionSOQL" value="SELECT Id FROM Account"/>
            <entry key="dataAccess.name" value="D:Data LoadSeed DataNPower Production - 16 Aug 12AccountExport.csv"/>
            <entry key="dataAccess.type" value="csvWrite"/>
            <entry key="dataAccess.writeUTF8" value="true" />
        </map>
        </property>
    </bean>
</beans>

在本文的结尾,你可以看到所有参数的描述。假设我们在dataloader的Bin文件夹下运行下面的命令:

Process.bat "directory path where we have file process-config.xml"  process Name

在我们的例子中Process的名字是Account,Process名字只是属性名。

Run Commandline Data Loader

运行上面的命令后,你的数据将导出到开始配置的”process-config.xml”文件中。

在处理dataloader命令行的时候,有机会你会遇到一些错误。所以我也列出一些常见的错误和解决方案:

错误 1: Dataloader error: “javax.crypto.BadPaddingException:”Or error loading parameter of sfdc.password 解决方法: 将 “process.encryptionKeyFile=C:\Users\315447\Desktop\Data Loader\key.txt”要么放在 “config.properties” 文件中,要么放在 “process-conf.xml文件中”

<entry key="process.encryptionKeyFile" value="config/key.txt"/>

错误 2: 查询错误: query is empty 解决方法: Occurs, If “sfdc.extractionSOQL” key in beans node does not have valid SOQL.

Parameters for Process-config.xml:

Process-Config.xml的一些参数

PARAMETER

DESCRIPTION

<bean id=" PROCESSNAME " class="com.salesforce.lexiloader.process.ProcessRunner" singleton="false">

This first line uniquely defines the process in the XML file. This has to be unique and will be used to call the process later on. Only change the PROCESSNAMEand leave all other parts the same.

<description> Your Description here </description>

A description of the process.

<property name="name" value="PROCESSNAME "/>

Copy the PROCESSNAME and place it in this parameter. This is used in the log files when debug messages are showing. This is the name that is shown on the debug logs.

<property name="configOverrideMap">

These two lines initiate the parameters for the process. They should not be changed and should always be the same.

<entry key="sfdc.debugMessages" value="false"/>

Set this to True if you want detailed debug messages to appear in the command line.

<entry key="sfdc.debugMessagesFile" value="c:\\dataloader\\samples\\status\\accountMasterSoapTrace.log"/>

Set the value to a directory and a file to keep the detailed log file in. WARNING: This can create an extremely large file. Make sure that you have space on your hard drive before this is set.

<entry key="sfdc.endpoint" value="https://www.salesforce.com"/>

Keep default, unless loading into Sandbox. for sandbox, it is test.salesforce.com.

<entry key="sfdc.username" value="jitendrazaa@winter13Sand.com" />

Set this as the username of the user you are importing /exporting as.

<entry key="sfdc.password" value="b6b3016135f717754590a3e35b1db32b" /><br/> <entry key="process.encryptonKeyFile" value="C:\\Program Files\\salesforce.com\\Apex Data Loader 9.0\\test\\Key.txt" />

See this article on how to create Encrypted password for Command line Dataloader in Salesforce

<entry key="sfdc.timeoutSecs" value="600"/>

System time out value.

<entry key="sfdc.loadBatchSize" value="200"/>

System batch load size.

<entry key="process.operation" value="extract" />

Signifies the process being run.Possible Values:ExtractInsertDeleteUpsert

<entry key="sfdc.entity" value="Account"/>

Signifies the object that you are running this process for. This should be the API name of the object when you are running processes for custom objects.

<entry key="sfdc.extractionRequestSize" value="500"/>

Batch size for extract processes only

This is the SOQL query run for extract processes. You can use the Data Loader GUI to generate the SOQL statement and conditions and simply cut and paste into this entry key.

<entry key="dataAccess.type" value="csvWrite" />

Signifies the action when doing the process for Extract, Insert, Delete, Upsert. This key should be used in conjunction with the "process.operation" key.Possible Values:csvReadcsvWritedatabaseReaddatabaseWriteWhen using Extract processes, use csvWrite. When using Delete, Insert, and Upsert processes, use csvRead.

<entry key="dataAccess.writeUTF8" value="true" />

When using a "csvWrite" dataccess type, set this to True when you want files to be extracted as UTF-8.

<entry key="dataAccess.name" value="<b>C:\\Program Files\\salesforce.com\\Apex Data Loader 9.0\\test\\extract.csv</b>" />

Signifies the location and file name of the dataaccess type process. If running a csvRead, the process will look for the file in this location. If running a csvWrite, the process will replace the file in this location.

<entry key="process.mappingFile" value="<b>C:\\Program Files\\salesforce.com\\Apex Data Loader 9.0\\test\\upsert_mapping.sdl</b>"/>

Signifies the location of a data loader mapping file. This is the same mapping file used when saving a mapping from the data loader GUI. This is required for insert, delete and upsert processes.

<entry key="sfdc.externalIdField" value="Customer_ID__c"/>

Signifies the External ID field used for the upsert process. This is required for upserts.

<entry key="process.statusOutputDirectory" value="C:\\Program Files\\salesforce.com\\Apex Data Loader 9.0\\test\\logs\\" />

Signifies the directory where the data loader success and error files will be created in.

<entry key="process.outputSuccess" value="C:\\Program Files\\salesforce.com\\Apex Data Loader 9.0\\test\\Logs\\csvUpsertProcess_success.csv" /><br/><br/> <entry key="process.outputError" value="C:\\Program Files\\salesforce.com\\Apex Data Loader 9.0\\test\\Logs\\csvUpsertProcess_error.csv" />

Signifies the directory and filename where the success and error files will be created. If this key is not specified, the "process.statusOutputDirectory" key will contain similar filenames as ones generated by the data loader GUI.

  • Extract
  • Insert
  • Delete
  • Upsert

<entry key="sfdc.entity" value="Account"/>Signifies the object that you are running this process for. This should be the API name of the object when you are running processes for custom objects.<entry key="sfdc.extractionRequestSize" value="500"/>Batch size for extract processes only This is the SOQL query run for extract processes. You can use the Data Loader GUI to generate the SOQL statement and conditions and simply cut and paste into this entry key.<entry key="dataAccess.type" value="csvWrite" />Signifies the action when doing the process for Extract, Insert, Delete, Upsert. This key should be used in conjunction with the "process.operation" key. Possible Values:

  1. csvRead
  2. csvWrite
  3. databaseRead
  4. databaseWrite

When using Extract processes, use csvWrite. When using Delete, Insert, and Upsert processes, use csvRead.<entry key="dataAccess.writeUTF8" value="true" />When using a "csvWrite" dataccess type, set this to True when you want files to be extracted as UTF-8.<entry key="dataAccess.name" value="<b>C:\\Program Files\\salesforce.com\\Apex Data Loader 9.0\\test\\extract.csv</b>" />Signifies the location and file name of the dataaccess type process. If running a csvRead, the process will look for the file in this location. If running a csvWrite, the process will replace the file in this location.<entry key="process.mappingFile" value="<b>C:\\Program Files\\salesforce.com\\Apex Data Loader 9.0\\test\\upsert_mapping.sdl</b>"/>Signifies the location of a data loader mapping file. This is the same mapping file used when saving a mapping from the data loader GUI. This is required for insert, delete and upsert processes.<entry key="sfdc.externalIdField" value="Customer_ID__c"/>Signifies the External ID field used for the upsert process. This is required for upserts.<entry key="process.statusOutputDirectory" value="C:\\Program Files\\salesforce.com\\Apex Data Loader 9.0\\test\\logs\\" />Signifies the directory where the data loader success and error files will be created in.<entry key="process.outputSuccess" value="C:\\Program Files\\salesforce.com\\Apex Data Loader 9.0\\test\\Logs\\csvUpsertProcess_success.csv" /><br/><br/> <entry key="process.outputError" value="C:\\Program Files\\salesforce.com\\Apex Data Loader 9.0\\test\\Logs\\csvUpsertProcess_error.csv" />Signifies the directory and filename where the success and error files will be created. If this key is not specified, the "process.statusOutputDirectory" key will contain similar filenames as ones generated by the data loader GUI.

本文分享自微信公众号 - CRM日记本(CRM_journal)

原文出处及转载信息见文内详细说明,如有侵权,请联系 yunjia_community@tencent.com 删除。

原始发表时间:2015-03-11

本文参与腾讯云自媒体分享计划,欢迎正在阅读的你也加入,一起分享。

我来说两句

0 条评论
登录 后参与评论

相关文章

  • 2017 Dreamforce大会中了解到的Salesforce Einstein进化与发展

    美国银行已经部署了Salesforce Einstein功能,包括Predictive Lead Scoring和Einstein Analytics(之前的W...

    臭豆腐
  • 什么是CPQ,以及为什么要选择Salesforce

    配置,价格,报价(Configure, Price, Quote),或称为CPQ,是帮助公司定义大量和不断变化变量的产品价格的软件。CPQ软件汇合这些变量,反过...

    臭豆腐
  • Radian6:社会化媒体的ROI

    知名的社会化媒体监测公司Radian6发表了关于《社会化媒体的ROI(投资回报率)》的白皮书,对社会化媒体投资回报率的疑点、真实情况和如何监测ROI进行了解读。...

    臭豆腐
  • 使用 Kind 搭建你的本地 Kubernetes 集群

    Kind[1] 是 Kubernetes In Docker 的缩写,顾名思义是使用 Docker 容器作为 Node 并将 Kubernetes 部署至其中的...

    Jintao Zhang
  • ASCII码排序

    输入第一行输入一个数N,表示有N组测试数据。后面的N行输入多组数据,每组输入数据都是占一行,有三个字符组成,之间无空格。输出对于每组输入数据,输出一行,字符中间...

    书童小二
  • <del>标签

    Html5知典
  • selenium+python自动化99--文件下载弹窗处理(PyKeyboard)

    在web自动化下载操作时,有时候会弹出下载框,这种下载框不属于web的页面,是没办法去定位的(有些同学一说到点击,脑袋里面就是定位!定位!定位!) 有时候我们并...

    上海-悠悠
  • 大文件拆分方案的Java实践【面试+工作】

    大文件拆分问题涉及到io处理、并发编程、生产者/消费者模式的理解,是一个很好的综合应用场景,为此,花点时间做一些实践,对相关的知识做一次梳理和集成,总结一些共性...

    奋斗蒙
  • 求解任意多边形的面积(平面内)

      平面内多边形的计算,也就是平面坐标系内多边形的计算,已知各定点坐标,有顺序的,逆时针或者顺时针。根据给出坐标求面积。

    用户2038589
  • [译]Android TensorFlow机器学习示例

    原文地址:<https://blog.mindorks.com/android-tensorflow-machine-learning-example- ff...

    MelonTeam

扫码关注云+社区

领取腾讯云代金券