Skip to content

Teradata

To connect to a Teradata database, is possible to import the TeradataConnector class from the hamana.connector.db.teradata module. As a shortcut, the TeradataConnector class is also available in the hamana.connector.db module as Teradata.

import hamana as hm

# connect database
teradata_db = hm.connector.db.Teradata(
    host = "localhost",
    port = 1025,
    user = "user",
    password = "password"
)

# perform operations
# ...

hamana.connector.db.teradata

TeradataConnector

TeradataConnector(
    user: str | None = None,
    password: str | None = None,
    host: str | None = None,
    database: str | None = None,
    port: int = 1025,
    logmech: str = "LDAP",
    **kwargs: Any
)

Bases: BaseConnector

Class representing a connector to a Teradata database.

Initialize the Teradata connector with the given parameters.
Teradata provides a whole range of options to configure the connection with the database, see teradatasql Documentation.
For this reasons, the most common parameters can be passed directly to the constructor, while all others can be specified directly as keyword arguments.

Parameters:

Name Type Description Default
user str | None

username to connect to the database.

None
password str | None

password to connect to the database.

None
host str | None

hostname or IP address of the Teradata database.

None
database str | None

name of the database to connect to.

None
port int

port of the Teradata database. Default is 1025.

1025
logmech str

logon mechanism to use for the connection. Default is "LDAP".

'LDAP'
**kwargs Any

additional keyword arguments to pass to the Teradata connection.

{}
Source code in src/hamana/connector/db/teradata.py
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
def __init__(
    self,
    user: str | None = None,
    password: str | None = None,
    host: str | None = None,
    database: str | None = None,
    port: int = 1025,
    logmech: str = "LDAP",
    **kwargs: Any
) -> None:
    """
        Initialize the Teradata connector with the given parameters.  
        Teradata provides a whole range of options to configure the connection 
        with the database, see `teradatasql` [Documentation](https://github.com/Teradata/python-driver).  
        For this reasons, the most common parameters can be passed directly to the constructor, 
        while all others can be specified directly as keyword arguments.

        Parameters:
            user: username to connect to the database.
            password: password to connect to the database.
            host: hostname or IP address of the Teradata database.
            database: name of the database to connect to.
            port: port of the Teradata database. Default is 1025.
            logmech: logon mechanism to use for the connection. Default is "LDAP".
            **kwargs: additional keyword arguments to pass to the Teradata connection.
    """
    logger.debug("start")

    # commons
    self.user = user
    self.password = password
    self.host = host
    self.database = database
    self.port = port
    self.logmech = logmech

    # additional parameters
    self.kwargs = kwargs

    # connection
    self.connection: Connection

    logger.debug("end")
    return