Extract API 2.0 Samples

This topic provides information about samples included with the Extract API.

Introduction

There are Extract API samples for Python, Java, and C/C++. Regardless of the language that the sample is written in, each sample provides the same functionality: creating and updating an extract.

You can find the samples in the samples directory of the Extract API. Before you can run the samples, ensure that you have installed the Extract API.

For more information on installing the Extract API, see Installing the Extract API 2.0.

Note: This version of the Extract API is only compatible with 10.5 and newer server installations.

Build and run the Python sample

Build the Python sample

  1. Open a terminal or command prompt and navigate to the directory where you installed the Extract API.

  2. Run the following command to build the packages you need to run the sample:

    python setup.py build
  3. Run the following command to install dependencies for the sample and copy files to your local Python packages directory:

    python setup.py install

Important: The Extract API only supports 64-bit versions of Python. If you do not run a 64-bit version of Python, the sample fails to build.

Run the Python sample

Navigate to the samples directory. Run the following command:

python tableauSDKSample.py <options>

To see all of the options available for the sample, see Sample Options, or use the --help option at the command line.;

Python Example

Create an extract:

python tableauSDKSample.py --build --filename your_data.hyper

Build and run the Java sample

Build the Java sample

To build the Java sample, you must have Apache Ant installed. For more information on downloading and installing Ant, see the Ant documentation. Then, complete the following steps.

  1. Open a terminal or command prompt and navigate to the same samples directory.

  2. Run the following command to build the sample:

    ant compile

Run the Java sample

Important: There are multiple ways to specify options to the Java sample from Ant, including from the command line and from the Ant build file. For simplicity's sake, the steps in this section describe how to provide arguments from the command line. For more information, see the Ant documentation on Writing a Buildfile.

  1. Open the following file in a text editor:

    samples/build.xml
  2. Find the following environment key line in the run target:

    <env key="${libPathKey}" path="${libPathValue}" />
  3. Verify that the following line appears after the environment key (if not, add it):

    <arg line="${args}" />
  4. Save the file.

  5. From the samples directory, run the following command to run the sample:

    ant run -Dargs="<options>"

To see all of the options available for the samples, see Sample Options.

Java Example

Create an extract:

ant run -Dargs="--build --filename your_data.hyper"

Build and run the C/C++ sample

Build the C/C++ sample

To build the C/C++ sample, you must have Visual Studio installed on Windows or make installed on other operating systems.

  1. Open a terminal or command prompt and navigate to the same samples directory.

    Important: On Windows, you must use nmake instead of make. The nmake utility is available from the Developer Command Prompt for Visual Studio. To open it, click the Start menu and search for "Developer Command Prompt". Make sure you select a Command Prompt that matches your platform, for example, VS2015 x64 Native Tools Command Prompt.

  2. Run one of the following make commands to build the sample for C or C++:

    make build-c

    Or:

    make build-cpp

Run the C++ sample

Important: There are multiple ways to specify options to the C/C++ sample from make, including from the command line and from the makefile. For simplicity's sake, the steps in this section describe how to provide arguments from the command line. For more information, see the Microsoft NMAKE Reference and the GNU make documentation.

  1. Open the following file in a text editor:

    samples/Makefile
  2. Find the lines for the C or C++ run step.

    For example, for C++, find the following lines:

    run-cpp : build-cpp
    .\TableauExtract APISample-cpp.exe
  3. Verify that the line has an argument variable appended to the run step like so:

    run-cpp : build-cpp
    .\TableauExtract APISample-cpp.exe $(ARGS)
  4. From the samples directory, run one of the following commands to run the C or C++ sample:

    make run-cpp ARGS="<options>"

    Or:

    make run-c ARGS="<options>"

To see all of the options available for the samples, see Sample Options.

C/C++ Examples

Create an extract:

make run-cpp ARGS="--build --filename your_data.hyper"

Sample options

The following table describes the options that you can specify when you run the samples from the command line:

Option Description
-b, --build Create or update the extract that you specify. Use in conjunction with the --filename option. If an extract exists with the given file name, open it and append data to it. If no such extract exists, create it.
-f, --filename Create or update the extract that you specify. Use in conjunction with the --build option.
-m, --multitable Create an extract that uses multiple-table storage. Use in conjunction with the --build option. Note that multiple-table storage for extracts is supported starting with Tableau 2018.3.
-s, --spatial Include spatial data in the extract. Use in conjunction with --build. If --build is not specified, or the extract being built is not newly created, this argument is ignored.

Thanks for your feedback! There was an error submitting your feedback. Try again or send us a message.