Connect to Teradata using Python
Overview
This how-to demonstrates how to connect to Teradata using teradatasql Python database driver for Teradata.
Prerequisites
-
64-bit Python 3.8 or later.
-
A Python virtual environment. The recommended workflow using system
venvis shown below. If you haveuvinstalled, an alternative workflow is provided.
teradatasql package runs on Windows, macOS (10.14 Mojave or later) and Linux. For Linux, currently only Linux x86-64 architecture is supported.
- Access to a Teradata instance. Currently driver is supported for use with Teradata Database 16.10 and later releases.
If you need a test instance of Teradata, you can provision one for free at https://www.teradata.com/try
Code to send a query
Create a file called app.py and paste in the following code. Fill in your host, username, and password before running:
Run the script from your terminal:
Summary
This how-to demonstrated how to connect to Teradata using teradatasql Python database driver. It described a sample Python code to send SQL queries to Teradata using teradatasql.