airflow.providers.teradata.hooks.teradata

An Airflow Hook for interacting with Teradata SQL Server.

Module Contents

Classes

TeradataHook

General hook for interacting with Teradata SQL Database.

class airflow.providers.teradata.hooks.teradata.TeradataHook(*args, database=None, **kwargs)[source]

Bases: airflow.providers.common.sql.hooks.sql.DbApiHook

General hook for interacting with Teradata SQL Database.

This module contains basic APIs to connect to and interact with Teradata SQL Database. It uses teradatasql client internally as a database driver for connecting to Teradata database. The config parameters like Teradata DB Server URL, username, password and database name are fetched from the predefined connection config connection_id. It raises an airflow error if the given connection id doesn’t exist.

You can also specify ssl parameters in the extra field of your connection as {"sslmode": "require", "sslcert": "/path/to/cert.pem", etc}.

Parameters
  • args – passed to DbApiHook

  • database (str | None) – The Teradata database to connect to.

  • kwargs – passed to DbApiHook

conn_name_attr = 'teradata_conn_id'[source]
default_conn_name = 'teradata_default'[source]
supports_autocommit = True[source]
conn_type = 'teradata'[source]
hook_name = 'Teradata'[source]
placeholder: str = '?'[source]
get_conn()[source]

Create and return a Teradata Connection object using teradatasql client.

Establishes connection to a Teradata SQL database using config corresponding to teradata_conn_id.

Returns

a Teradata connection object

Return type

teradatasql.TeradataConnection

bulk_insert_rows(table, rows, target_fields=None, commit_every=5000)[source]

Insert bulk of records into Teradata SQL Database.

This uses prepared statements via executemany(). For best performance, pass in rows as an iterator.

Parameters
  • table (str) – target Teradata database table, use dot notation to target a specific database

  • rows (list[tuple]) – the rows to insert into the table

  • target_fields (list[str] | None) – the names of the columns to fill in the table, default None. If None, each rows should have some order as table columns name

  • commit_every (int) – the maximum number of rows to insert in one transaction Default 5000. Set greater than 0. Set 1 to insert each row in each transaction

get_sqlalchemy_engine(engine_kwargs=None)[source]

Return a connection object using sqlalchemy.

static get_ui_field_behaviour()[source]

Return custom field behaviour.

Was this entry helpful?