By using this site, you acknowledge that you have read and understand our Cookie policy, Privacy policy and Terms .
close

Tutorials and informations about Teradata.

rss_feed Subscribe RSS

Teradata published an official Python module which can be used in DevOps projects. More details can be found at the following GitHub site: https://github.com/Teradata/PyTd

Install Teradata module

If pip is installed, you can directly install this module through the following command:

pip install Teradata

If not, you can download the package in the following URL:

https://pypi.python.org/pypi/teradata

After downloading, unzip the package and then use command prompt to navigate to the directory that contains setup.py file and then run the following command to install:

python setup.py install

Sample Code

"""Test teradata driver"""
import teradata
import sys
udaExec = teradata.UdaExec(
appName="HelloWorld", version="1.0", logConsole=False)
session = udaExec.connect(method="odbc", dsn="td16vm",
username="dbc", password="dbc", autocommit=True,
transactionMode="Teradata")
for row in session.execute('select getqueryband();'):
print(row)
for row in session.execute('select top 10 tablename, tablekind from dbc.tables;'):
print(row)
session.close()
input('Type <Enter> to exit...')

Details about the sample code

When connecting to Teradata, the following parameters can be configured:

https://developer.teradata.com/tools/reference/teradata-python-module#ConnectParametrs

In the sample code, transaction mode is set as Teradata; auto commit is set as True (transactions will be committed automatically); connecting method is ODBC (the other options is REST), DSN is using td16vm which was setup using the following parameters in my computer:

image

image

Setup your own Teradata virtual machine

If you have no Teradata instance, you can setup one following this post:

Install Teradata Express 15.0.0.8 by Using VMware Player 6.0 in Windows

Sample code result

The following screenshot shows the running result in my IDE (Visual Studio Code):

image

info Last modified by Administrator at 2 months ago * This page is subject to Site terms.

info About author

More from Kontext

local_offer pyspark local_offer spark-2-x local_offer python

visibility 146
thumb_up 0
access_time 2 months ago

This articles show you how to convert a Python dictionary list to a Spark DataFrame. The code snippets runs on Spark 2.x environments. Input The input data (dictionary list looks like the following): data = [{"Category": 'Category A', 'ItemID': 1, 'Amount': 12.40}, ...

open_in_new View

local_offer python local_offer pandas

visibility 14
thumb_up 0
access_time 2 months ago

Pickle files are commonly used Python data related projects. This article shows how to create and load pickle files using Pandas.&nbsp; Create pickle file import pandas as pd import numpy as np file_name="data/test.pkl" data = np.random.randn(1000, 2) # pd.set_option('displ...

open_in_new View

local_offer pyspark local_offer spark-2-x local_offer spark local_offer python

visibility 49
thumb_up 0
access_time 2 months ago

This article shows how to convert a Python dictionary list to a DataFrame in Spark using Python. Example dictionary list data = [{"Category": 'Category A', "ID": 1, "Value": 12.40}, {"Category": 'Category B', "ID": 2, "Value": 30.10}, {"Category": 'Category C', "...

open_in_new View

local_offer python local_offer pyspark local_offer pandas

visibility 1696
thumb_up 0
access_time 7 months ago

In Spark, it’s easy to convert Spark Dataframe to Pandas dataframe through one line of code: df_pd = df.toPandas() In this page, I am going to show you how to convert a list of PySpark row objects to a Pandas data frame. Prepare the data frame The fo...

open_in_new View

comment Comments (3)

comment Add comment

Please log in or register to comment. account_circle Log in person_add Register
R
Raymondarrow_drop_down

Hi, is your issue resolved?  If not, please paste your detailed error messages here. 


format_quote

person U-zq6ze96t4mhbvsp2 access_time 12 months ago
Re: Connect to Teradata database through Python

thx a lot for this tutorial. But I have a problem to ensure the connection of python (installed into windows) to Teradata (installed into VMWare in the same computer).

What shoul I do?

reply Reply
R
Raymondarrow_drop_down

Hi,

Did you setup the ODBC data source successfully?

If you are encountering connection issues from your windows host to the VM, you can check my following post to ensure the connection is well established:

Connect to Teradata Virtual Machine Guest from Windows Host


format_quote

person U-zq6ze96t4mhbvsp2 access_time 12 months ago
Re: Connect to Teradata database through Python

thx a lot for this tutorial. But I have a problem to ensure the connection of python (installed into windows) to Teradata (installed into VMWare in the same computer).

What shoul I do?

reply Reply
A
Anonymousarrow_drop_down

thx a lot for this tutorial. But I have a problem to ensure the connection of python (installed into windows) to Teradata (installed into VMWare in the same computer).

What shoul I do?


reply Reply
info Follow us on Twitter to get the latest article updates. Follow us