SnowConvert Scripts Helpers
SnowConvert Helpers is a set of classes with functions designed to facilitate the conversion of Teradata script files to Python files that Snowflake can interpret.
SnowConvert for Teradata can take in any Teradata SQL or scripts (BTEQ, FastLoad, MultiLoad, and TPump) and convert them to functionally equivalent Snowflake SQL, JavaScript embedded in Snowflake SQL, and Python. Any output Python code from SnowConvert will call functions from these helper classes to complete the conversion and create a functionally equivalent output in Snowflake.
The Snowflake Connector for Python will also be called in order to connect to your Snowflake account and run the output Python code created by SnowConvert.
The latest version information of the package can be found here.
The Python packagesnowconvert-helpers
supports Python versions 3.6, 3.7, 3.8, and 3.9.
Script Migration
Source
Suppose you have the following BTEQ code to be migrated.
Output
You should get an output like the one below.
The log_on
function parameters ('user', 'password', 'account', 'database', 'warehouse', 'role', 'token') should be defined by the user.
Getting Started
To install the package, you should run the following command in your python environment. If you're not familiar with installing packages in Python, visit the following page on python packages (https://packaging.python.org/tutorials/installing-packages/).
Once your package is installed, you will be able to run the script migrated code in Python.
Run the code
To run the migrated code, you just have to open the Command Prompt
or the Terminal
and execute the following command.
If the script has no errors, you will get in your console an output like the one below.
Passing connection parameters
There are several ways to pass the connection parameters to the connection of the database:
As parameters in the function call snowconvert.helpers.log_on inside the python file.
As positional parameters with the specific order of user, password, account, database, warehouse, and role when the python is being executed from the command line.
As named parameters with no order restriction of SNOW_USER, SNOW_PASSWORD, SNOW_ACCOUNT, SNOW_DATABASE, SNOW_WAREHOUSE, SNOW_ROLE, SNOW_QUERYTAG, SNOWAUTHENTICATOR and SNOWTOKEN when the python is being executed from the command line and any of them are passed like --param-VARNAME=VALUE.
As environment variables named SNOW_USER, SNOW_PASSWORD, SNOW_ACCOUNT, SNOW_DATABASE, SNOW_WAREHOUSE, SNOW_ROLE, SNOW_QUERYTAG, SNOWAUTHENTICATOR and SNOWTOKEN before python execution.
The previous order specified is the way to determine the precedence.
Parameters in the function call
They can be set as positional parameters in the function call as follows.
Or they can be set any of the named parameters in any order in the function call as follows.
Positional parameters
They need to be set in the specific order in the command line as follows.
Or they can be set only some of the parameters but always starting with the user parameter as follows.
Named parameters
They can be set any of the named parameters in any order in the command line as follows (use a single line, multiline shown for readability reasons).