从命令行刷新流程输出文件

  • 版本 :2022.1 及更高版本

在 Tableau Prep Builder 中受支持。 您可以从命令行运行流程以刷新流程输出,而不是从 Tableau Prep Builder 运行流程。可以使用此方法一次运行一个流。此选项在安装了 Tableau Prep Builder 的 Windows 和 Mac 计算机上都可用。 注意:如果您使用的是基于登录名的许可证管理 (LBLM),请确保定期打开 Tableau Prep。否则租约可能会过期,从而导致通过命令行运行的流程失败。您还可以与管理员联系,将租约持续时间更改为最大长度。看基于登录的许可证管理(链接在新窗口中打开)了解更多信息。

连接器限制:

  • JDBC 或 ODBC 连接器:从版本 2019.2.3 开始,可以从命令行运行包含这些连接器的流。

  • 云连接器:包含云连接器(如 Google BigQuery)的流无法从命令行运行。相反,请使用 Tableau Prep Conductor 在 Tableau ServerTableau Online 中手动运行流程或按计划运行流程。有关详细信息,请参阅使流数据保持最新

  • 单一登录身份验证:如果使用单一登录身份验证,则不支持从命令行运行流。您可以改为从 Tableau Prep Builder 运行流程。

对于 Windows 计算机,还可以使用 Windows 任务计划程序计划此过程。有关详细信息,请参阅任务计划程序(链接在新窗口中打开)在微软在线帮助中。

从命令行运行流程时,Tableau Prep Builder 将使用 Tableau Prep Builder 中指定的输出步骤的设置刷新流程的所有输出。有关如何指定输出位置的信息,请参阅创建数据提取文件和已发布的数据源(链接在新窗口中打开).有关设置写入选项(版本 2020.2.1 及更高版本)的信息,请参阅配置写入选项

运行流程之前

若要从命令行运行流,需要对运行流的计算机具有管理员权限,并且需要以下信息:

  • 安装 Tableau Prep Builder 的路径。

  • 如果连接到数据库并将输出文件发布到服务器或数据库(版本 2020.3.1 及更高版本),请创建包含所有必需凭据的凭据 .json 文件。

  • Tableau Flow (.tfl) 文件所在的路径。

凭据 .json 文件要求

注意:如果流连接到本地文件、存储在网络共享上的文件或使用 Windows 身份验证 (SSPI) 的输入文件并输出到本地文件,则不需要凭据 .json 文件。有关 Windows 身份验证的详细信息,请参阅SSPI 模型(链接在新窗口中打开)在微软在线帮助中。

当您具有远程连接时,Tableau Prep Builder 使用流文件和凭据 .json 文件中的信息来运行流。例如,远程连接的数据库名称和输出文件的项目名称来自流,服务器名称和登录凭据来自凭据 .json 文件。

  • 如果您计划重复使用该文件,请将其放在一个文件夹中,该文件夹不会被 Tableau Prep Builder 安装过程覆盖。

  • 如果运行的流包含以下任何内容,则必须包含包含连接所需凭据的 .json 文件。

    • 连接到数据库文件或已发布的数据源。

    • 输出将发布到服务器或数据库(版本 2020.3.1 及更高版本)。

    • 该流包括 Rserve 或 TabPy 的脚本步骤。.json 文件必须包含连接到这些服务所需的凭据。有关详细信息,请参阅下面适用于您的版本的阵列要求。

  • 流中指定的凭据和 .json 文件中包含的凭据必须匹配,否则流将无法运行。

  • 运行该进程时,主机名、端口和用户名将用于在 Tableau 流文件 (.tfl) 中查找匹配的连接,并在运行该进程之前进行更新。端口 ID 和站点 ID 是可选的,如果你的连接不需要此信息。

  • 如果连接到已发布的数据源,请在输入连接中包括主机名、contentUrl 和端口(http 为 80,https 为 443)。在 Tableau 流文件 (.tfl) 中查找匹配的连接需要主机名,并且内容 Url 和端口用于建立与服务器的连接。

  • 如果连接到 Tableau Online,请在要连接到的容器的输入连接中包含端口(80 或 443)。有关 Tableau Online 的详细信息,请参阅Tableau Bridge 连接到 Tableau Online(链接在新窗口中打开)在 Tableau Online 帮助中。

  • (版本 2021.4.1 及更高版本)如果在流中包含参数,则可以在命令行中创建并包含参数覆盖 .json 文件,以更改参数值与当前默认值相比。有关详细信息,请参阅运行包含参数值的流

根据您的 Tableau Prep Builder 版本,您的凭据信息的格式可能会有所不同。单击下面的选项卡以查看您的 Tableau Prep Builder 版本的凭据格式。

Depending on your connections, include your server or database credentials or both. When your flow connects to and outputs to the same server or database, you only need to include a single block in the .json file. If you connect to a server or database that uses different credentials, use a comma delimited array.

Server connectionsDatabase connectionsRserver or Tableau Python connections

Connection block name: "tableauServerConnections"

Include the following data in the array:

  • serverUrl (Server name)

  • contentUrl (Site ID. This appears after /site/ in the URL for Tableau Server or Tableau Online. For example "https://my.server/#/site/mysite" set .))"contentUrl": "mysite"

  • port (Port ID)

  • username

  • password

Connection block name: "databaseConnections"

Include the following data in the array:

  • hostname (Server name)

  • port (Port ID)

  • username

  • password

Only include this array if your flow includes script steps for R or TabPy.

Connection block name: "extensions"

Include the following data in the array:

  • extensionName: Specify or "rSupport""pythonSupport"

  • regular: Include "host"and "port". You can also include "username" or "sslCertificate" (content of your public .pem file encoded as base64 string) if applicable.

  • sensitive: Include "password" if you use one. Otherwise include a blank array.

Note: ContentUrl is always required in the .json file for sever connections. If connecting to a default site, for example "https://my.server/#/site/", set ContentUrl to blank. For example "contentUrl": ""

Run flows that include parameter values

Supported in Tableau Prep Builder version 2021.4.1 and later.

To run flows from the command line that include parameter values, you can create a parameters override .json file that includes the parameter values that you want to use. These values override the current (default) values defined for the parameters.

This is a separate file from your credentials.json file and includes your parameter names and values.

Note: Starting in version 2022.1.1, parameter values no longer need to be enclosed in quotes. In prior versions, all parameter names and values must include quotes.

Example:

{
    "Parameter 1": Value 1,
    "Number Parameter": 40,
    "Boolean Parameter": True
}				

When you run the flow include -p --parameters and the name of your file in the command line.

Examples:

Windows

 "\[Tableau Prep Builder install location]\Tableau Prep Builder \scripts"\tableau-prep-cli.bat -t "path\to\[your flow file name].tfl" -p|--parameters parameters.override.json

Mac

/Applications/Tableau\ Prep\ Builder\ [Tableau Prep Builder version].app/Contents/scripts/./tableau-prep-cli -t path/to/[your flow file name].tfl -p|--parameters parameters.override.json

Examples

This section shows different examples of credentials files that you can create using the credentials .json requirements.

Connecting to a server connection

This example shows a .json credentials file that connects to and outputs to a server connection that uses the same credentials:

{
 "tableauServerConnections":[
   {
    "serverUrl":"https://my.server",
    "contentUrl": "mysite",
    "port":443,
    "username": "jsmith",
    "password": "passw0rd$"
   }
 ]
}				

Connecting to a server connection and output to a database connection

This example shows a .json credentials file that connects to a server connection and outputs to a database connection:

{
 "tableauServerConnections":[
   {
    "serverUrl":"https://my.server",
    "contentUrl": "mysite",
    "port":443,
    "username": "jsmith",
    "password": "passw0rd$"
   }
],
 "databaseConnections":[
   {
    "hostname":"example123.redshift.amazonaws.com",
    "port":"5439",
    "username":"jsmith",
    "password":"p@s$w0rd!"
   }
 ]
}

Flow includes Rserve and TabPy script connections and outputs to a database connection

This example shows a .json credentials file that includes Rserve and Tabpy credentials and outputs to a database connection:

{
 "extensions": [
    {
	  "extensionName": "rSupport",
	  "regular": {
		"host": "localhost",
		"port": "9000",
		"username": "jsmith"
	},
	"sensitive": {	
	  "password": "pwd"	
	}
   },
   {
	"extensionName": "pythonSupport",
	"regular": {
	  "host": "localhost",
	  "port": "9000"
	},
	"sensitive": {
	}
   }
 ],										
 "databaseConnections":[
   {
    "hostname":"example123.redshift.amazonaws.com",
    "port": "5439",
    "username": "jsmith",
    "password": "p@s$w0rd!"
   },
   {
    "hostname":"mysql.mydb.tsi.lan",
    "port": "3306",
    "username": "jsmith",
    "password": "mspa$$w0rd"
   }
 ]
}			

Connecting to and outputting to different database connections

This example shows a .json credentials file that connects to and outputs to different database connections:

{
 "databaseConnections":[
{
  "hostname":"example123.redshift.amazonaws.com",
  "port": "5439",
  "username": "jsmith",
  "password": "p@s$w0rd!"
 },
 {
   "hostname":"mysql.mydb.tsi.lan",
   "port": "3306",
   "username": "jsmith",
   "password": "mspa$$w0rd"
  }
 ]
}			

Tips for creating your credentials file

To avoid errors when running the flow, make sure your credentials file follows these guidelines:

  • If using Tableau Prep Builder version 2018.2.2 through 2018.3.1, always include the "inputConnections" and "outputConnections" arrays even if the flow doesn't have remote connections for inputs or outputs. Just leave those arrays blank.

    If you are using Tableau Prep Builder version 2018.3.2 and later you don't need to include the blank array.

    • No remote input connection? Include this syntax at the top of the .json file

      {
       "inputConnections":[
        ],
    • No remote output connection? Include this syntax at the bottom of the .json file

    • "outputConnections":[
        ]
      }
  • No port ID for your input connection or the port is specified as part of the server name.

    If there is no port ID for your connection, don't include the reference in the .json file, not even . If the port ID is included in the server name, include the port ID in the host name. For example "port":xxxx,"port": """hostname": "mssql.example.lan,1234"

  • When referencing the don't include a "/" at the end of the address. For example, use this not this ."serverUrl":"serverUrl": "http://server""serverUrl": "http://server/"

  • If you have multiple input or output connections include the credentials for each one in the file.

  • If connecting to published data sources, make sure to include the hostname and contentUrl in the input connections.

Run the flow

Important: The examples below include the name change for "Tableau Prep" version 2019.1.2 to "Tableau Prep Builder". If you are using an earlier version of the product use "Tableau Prep" instead.

  1. Open the command prompt or terminal command prompt (MacOS) as an Administrator.

  2. Run one of the following commands using the syntax shown below.

    • The flow connects to local files or files stored on a network share and publishes to local files, files stored on a network share or uses Windows authentication:

      Note: If connecting to or outputting to files stored on a network share, use the UNC format for the path: \\server\path\file name. It can't be password protected.

      Windows

       "\[Tableau Prep Builder install location]\Tableau Prep Builder \scripts"\tableau-prep-cli.bat -t "path\to\[your flow file name].tfl"

      Mac

      /Applications/Tableau\ Prep\ Builder\ [Tableau Prep Builder version].app/Contents/scripts/./tableau-prep-cli -t path/to/[your flow file name].tfl
    • The flow connects to databases or publishes to a server:

      Windows

      "\[Tableau Prep Builder install location]\Tableau Prep Builder \scripts"\tableau-prep-cli.bat -c "path\to\[your credential file name].json" -t "path\to\[your flow file name].tfl"

      Mac

      /Applications/Tableau\ Prep\ Builder\ [Tableau Prep Builder version].app/Contents/scripts/./tableau-prep-cli -c path/to/[your credential file name].json -t path/to/[your flow file name].tfl
    • The flow file or credentials file is stored on a network share (use the UNC format for the path: \\server\path\file name):

      Windows

      "\[Tableau Prep Builder install location]\Tableau Prep Builder \scripts"\tableau-prep-cli.bat -c "\server\path\[your credential file name].json" -t "\server\path\[your flow file name].tfl"

      Mac: Map the network share to /Volumes in Finder so that it is persistent, then use to specify the path:/Volumes/.../[your file]

      /Applications/Tableau\ Prep\ Builder\ [Tableau Prep Builder version].app/Contents/scripts/./tableau-prep-cli -c /Volumes/.../[your credential file name].json -t path/to/[your flow file name].tfl

For common errors and resolutions see Common errors when using the command line to run flows.

Run the flow with incremental refresh enabled

Supported in Tableau Prep Builder version 2020.2.1 and later, and on the web starting in version 2020.4. Incremental refresh is not currently supported when writing flow outputs to Microsoft Excel.

If you don't have Tableau Prep Conductor enabled on your server to schedule your flow runs, you can run your flow using incremental refresh from the command line. Simply include the parameter in your command line as shown in the example below. --incrementalRefresh

Windows

 "\[Tableau Prep Builder install location]\Tableau Prep Builder \scripts"\tableau-prep-cli.bat --incrementalRefresh -t "path\to\[your flow file name].tfl"

Mac

/Applications/Tableau\ Prep\ Builder\ [Tableau Prep Builder version].app/Contents/scripts/./tableau-prep-cli --incrementalRefresh -t path/to/[your flow file name].tfl

If the input steps in your flow have incremental refresh enabled and the incremental refresh parameters are properly configured, Tableau Prep Builder will do the following:

  • All inputs in the flow that have incremental refresh enabled will run all corresponding outputs using incremental refresh.

  • If no input in the flow has incremental refresh enabled, all outputs will be run using full refresh. A message will show the refresh method details.

  • If some inputs in the flow have incremental refresh enabled, the corresponding outputs will run using incremental refresh. The other outputs will be run using full refresh and a message will show the refresh method details.

For more information about configuring flows to use incremental refresh, see Refresh Flow Data Using Incremental Refresh

Command options

If you want to view the help options, include in the command line. -h

Command optionsDescriptionNotes
-c , --connectionsThe connection path to the credentials file.Requires the path to where the credentials file is located.
-d, --debugDebug the flow process.Include this option to view more information to help debug a problem with refreshing the flow. Log files are stored in: My Tableau Prep Builder Repository\Command Line Repository\Logs
-dsv, --disableSslValidationDisable SSL validation (MacOS)When running flows using the command line on the MacOS, a dialog may show asking for the keychain user and password. Starting with Tableau Prep Builder version 2019.3.2, you can pass in this additional parameter to disable this keychain dialog. For example: /Applications/Tableau\ Prep\ Builder\ [Tableau Prep Builder version].app/Contents/scripts/./tableau-prep-cli -dsv -c path/to/[your credential file name].json -t path/to/[your flow file name].tfl
-h, --helpView the help for syntax options.

The help option or a syntax error shows the following information:

usage: tableau-prep-cli [-c <arg>] [-d]  [-h] [-t <arg>]
-c,--connections <arg>        Path to a file with all connection information
-d,--debug                    This option is for debugging
-dsv,--disableSslValidation   Disable SSL validation
-h,--help                     Print usage message
-inc,--incrementalRefresh     Run incremental refresh for all outputs that are configured to support it
-t,--tflFile <arg>            The Tableau Prep Builder flow file	
-inc, --incrementalRefreshRun incremental refresh for all outputs that are configured to use it.

Include this option to run incremental refresh for all inputs that are configured to use it. Incremental refresh enables Tableau Prep Builder to retrieve and process only new rows instead of all rows in a flow.

The incremental refresh configuration settings on the input steps determine which flow outputs can be run incrementally. All other outputs will be run using a full refresh and a message will show the refresh method details.

For more information about running flows using incremental refresh, see Refresh Flow Data Using Incremental Refresh .

-t, --tflFileThe .tfl flow fileRequires the path to where the .tfl flow file is located.
-p, --parametersThe parameters override .json fileInclude this file if you want to override the current (default) parameter values applied to your flow. For more information about using flow parameters, see Create and Use Parameters in Flows

Syntax examples

The command lines below show four different examples for running a flow using the following criteria:

  • Tableau Prep Builder version: 2022.1.1

    Important: The examples below include the name change for Tableau Prep version 2019.1.2 to Tableau Prep Builder. If you are using an earlier version of the product use "Tableau Prep" instead.

  • Flow name: Flow1.tfl

  • Flow location: C:\Users\jsmith\Documents\My Tableau Prep Builder Repository\Flows

  • Credentials file name: Flow 1.json

  • Credentials file location: C:\Users\jsmith\Desktop\Flow credentials

  • Credentials file location stored on a network share: \tsi.lan\files\Flow credentials

The flow connects to and publishes to local files

Windows

"\Program Files\Tableau\Tableau Prep Builder 2022.1.1\scripts"\tableau-prep-cli.bat -t "\C:\Users\jsmith\Documents\My Tableau Prep Builder Repository\Flows\Flow1.tfl"

Mac

/Applications/Tableau\ Prep\ Builder\ 2022.1.1.app/Contents/scripts/./tableau-prep-cli -t /Users/jsmith/Documents/My\ Tableau\ Prep\ Builder\ Repository/Flows.Flow1.tfl

The flow connects to and publishes to local files and uses the short form for incremental refresh

Windows

"\Program Files\Tableau\Tableau Prep Builder 2022.1.1\scripts"\tableau-prep-cli.bat -inc -t "\C:\Users\jsmith\Documents\My Tableau Prep Builder Repository\Flows\Flow1.tfl"

Mac

/Applications/Tableau\ Prep\ Builder\ 2022.1.1.app/Contents/scripts/./tableau-prep-cli -inc -t /Users/jsmith/Documents/My\ Tableau\ Prep\ Builder\ Repository/Flows.Flow1.tfl

The flow connects to databases and publishes to a server

Windows

"\Program Files\Tableau\Tableau Prep Builder 2022.1.1\scripts"\tableau-prep-cli.bat -c "\C:\Users\jsmith\Desktop\Flow credentials\Flow1.json" -t "\C:\Users\jsmith\Documents\My Tableau Prep Builder Repository\Flows\Flow1.tfl"

苹果电脑

/Applications/Tableau\ Prep\ Builder\ 2022.1.1.app/Contents/scripts/./tableau-prep-cli -c /Users/jsmith/Desktop/Flow\ credentials/Flow1.json -t /Users/jsmith/Documents/My\ Tableau\ Prep\ Builder\ Repository/Flows.Flow1.tfl

流发布到服务器,凭据文件存储在网络共享上

窗户

"\Program Files\Tableau\Tableau Prep Builder 2022.1.1\scripts"\tableau-prep-cli.bat -c "\\tsi.lan\files\Flow credentials\Flow1.json" -t "\C:\Users\jsmith\Documents\My Tableau Prep Builder Repository\Flows\Flow1.tfl"

苹果电脑

/Applications/Tableau\ Prep\ Builder\ 2022.1.1.app/Contents/scripts/./tableau-prep-cli -c /Volumes/files/Flow\ crede