Python JayDeBeApi module allows you to connect from Python to Teradata databases using Java JDBC drivers. In article Connect to Teradata database through Python, I showed how to use teradata package to connect to Teradata via Teradata ODBC driver. This article demos how to use this JayDeBeApi package.

About JayDeBeApi

Find more details about JayDeBeApi from the this pypy index page:

Make sure Python and pip is installed in your machine. 

Run the following command to install this package.

pip install JayDeBeApi

About Teradata JDBC driver

Teradata JDBC driver is required.

The following two JAR files are required:

  • tdgssconfig.jar
  • terajdbc4.jar

You can download it from:

  1. Teradata Download:
  2. Maven Repository:
  3. Or any other repositories.

Code snippet

Similar as the SQL Server example (Connect to SQL Server via JayDeBeApi in Python), you can connect to Teradata using JayDeBeApi.

import jaydebeapi

database = "test"
table = "Employees"
user = "zeppelin"
password = "zeppelin"
driver = 'com.teradata.jdbc.TeraDriver'

conn = jaydebeapi.connect(driver,
                          [user, password],
curs = conn.cursor()

curs.execute('create table test.test_jaydebeapi'
             '("ID" INTEGER not null,'
             ' "NAME" VARCHAR not null,'
             ' primary index ("ID"))'
curs.execute("insert into test.test_jaydebeapi values (1, 'Raymond')")
curs.execute("select * from test.test_jaydebeapi")
curs.execute("update test.test_jaydebeapi set NAME='RAY' WHERE ID=1")
curs.execute("delete from test.test_jaydebeapi ALL")

In the above code snippet, the connection is established using connect function. Login mechanism is LADP and you can remove it if you use database user name and password to login. Remember to change the JAR file paths accordingly (absolute paths are preferable). 

Once connection is established, you can create a cursor object through which you can perform the following actions:

  • CREATE/DROP tables/other objects
  • or any other valid Teradata SQL statement.

For SELECT statement, you can use fetchall or fetchfirst functions to retrieve records. 


Load Data from Teradata in Spark (PySpark)

Quick question - why do we not to use PySpark JDBC read/write functions to perform transactional operations against Teradata database? 

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

More from Kontext

local_offer teradata local_offer python

visibility 222
thumb_up 0
access_time 2 months ago

Pandas is commonly used by Python users to perform data operations. In many scenarios, the results need to be saved to a storage like Teradata. This article shows you how to do that easily using JayDeBeApi or  ...

open_in_new View open_in_new Spark + PySpark

local_offer python

visibility 63
thumb_up 0
access_time 2 months ago

CSV is a common data format used in many applications. It's also a common task for data workers to read and parse CSV and then save it into another storage such as RDBMS (Teradata, SQL Server, MySQL). In my previous article  ...

open_in_new View open_in_new Python Programming

local_offer teradata local_offer SQL

visibility 29
thumb_up 0
access_time 2 months ago

In SQL Server, we can use TRUNCATE statement to clear all the records in a table and it usually performs better compared with DELETE statements as no transaction log for each individual row deletion. The syntax looks like the following: TRUNCATE TABLE {

open_in_new View open_in_new Code snippets

local_offer hadoop local_offer hive local_offer Java

visibility 193
thumb_up 1
access_time 2 months ago

When I was configuring Hive 3.0.0 in Hadoop 3.2.1 environment, I encountered the following error: Exception in thread "main" java.lang.NoSuchMethodError:;Ljava/lang/Object;)V Ro...

open_in_new View open_in_new Hadoop

info About author

Dark theme mode

Dark theme mode is available on Kontext.

Learn more arrow_forward

Kontext Column

Created for everyone to publish data, programming and cloud related articles. Follow three steps to create your columns.

Learn more arrow_forward