airflow.providers.teradata.hooks.teradata
¶
An Airflow Hook for interacting with Teradata SQL Server.
Module Contents¶
Classes¶
General hook for interacting with Teradata SQL Database. |
Attributes¶
- 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}
.See also
- Parameters
args – passed to DbApiHook
database (str | None) – The Teradata database to connect to.
kwargs – passed to DbApiHook
- 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
- set_query_band(query_band_text, teradata_conn)[source]¶
Set SESSION Query Band for each connection session.
- 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.
- Parameters
table (str) – target Teradata database table, use dot notation to target a specific database
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
- 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.
- Parameters
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.