setup_sto_env | Script Method | Teradata Python Package - 17.00 - setup_sto_env - Teradata Package for Python

Teradata® Package for Python User Guide

Teradata Package for Python
Release Number
Release Date
November 2021
Content Type
User Guide
Publication ID
English (United States)

Use the setup_sto_env method to load already downloaded sandbox image. See Script for details about sandbox environment.

Teradata recommends using setup_sandbox_env() function available from teradataml, instead of this setup_sto_env method from previous release.

The setup_sto_env method features only one argument: docker_image_location. This required argument specifies the location of the sandbox image on user's system.


To run this example, "" and "barrier.csv" are required and must be present under the same location specified by the argument files_local_path.
  • "barrier.csv" is present under <teradataml_install_location>/teradataml/data directory.
  • "" can be created as follows:
    import sys
    for line in sys.stdin:
        line = line.strip()
        words = line.split()
        for word in words:
            print ('%s\t%s' % (word, 1))
  • Load example data.
    >>> load_example_data("Script", ["barrier"])
  • Import required packages.
    >>> from collections import OrderedDict
    >>> from teradatasqlalchemy import (VARCHAR)
  • Create teradataml DataFrame.
    >>> barrierdf = DataFrame.from_table("barrier")
  • Create a Script object to run script on Vantage.
    >>> sto = Script(data=barrierdf,
                files_local_path= 'data/scripts',
                script_command='python3 ./<database name>/',
                charset='latin', returns=OrderedDict([("word", VARCHAR(15)), ("count_input", VARCHAR(2))])
  • Run the script locally within Docker container using data from csv.

    This helps users to fix script level issues outside Vantage.

    >>> sto.setup_sto_env(docker_image_location='/tmp/sto_sandbox_docker_image.tar'))
    Loading image from /tmp/sto_sandbox_docker_image.tar. It may take few minutes.
    Image loaded successfully.
    Starting a container for stosandbox:1.0 image.
    Container c1dd4d4b722cc54b643ab2bdc57540a3a3e6db98c299defc672227de97d2c345 started successfully.