An Airflow Hook for interacting with Teradata SQL Server.

Module Contents



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}.

  • 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]
supports_executemany = True[source]
conn_type = 'teradata'[source]
hook_name = 'Teradata'[source]
placeholder: str = '?'[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.


a Teradata connection object

Return type


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

Use insert_rows() instead, this is deprecated.

Insert bulk of records into Teradata SQL Database.

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

  • 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 row 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


Return a connection object using sqlalchemy.

static get_ui_field_behaviour()[source]

Return custom field behaviour.

callproc(identifier, autocommit=False, parameters=None)[source]

Call the stored procedure identified by the provided string.

Any OUT parameters must be provided with a value of either the expected Python type (e.g., int) or an instance of that type.

  • identifier (str) – stored procedure name

  • autocommit (bool) – What to set the connection’s autocommit setting to before executing the query.

  • parameters (list | dict | None) – The IN, OUT and INOUT parameters for Teradata stored procedure

The return value is a list or mapping that includes parameters in both directions; the actual return type depends on the type of the provided parameters argument.

Was this entry helpful?