Teradata R Package Function Reference | 17.00 - 17.00 - dbConnect for NativeDriver - Teradata R Package

Teradata® R Package Function Reference

prodname
Teradata R Package
vrm_release
17.00
created_date
September 2020
category
Programming Reference
featnum
B700-4007-090K

Description

Use the dbConnect(tdplyr::NativeDriver(), ...) function to establish a connection to Teradata Vantage using the Teradata SQL driver for R (also called the native driver for R) and initialize a context.

Note:

  • If there is no previous context, then a new context is initialized.

  • If the context already exists, then

    1. the previous context is overwritten and all non-persistent work tables are removed if the connection parameters host, uid and database (i.e., default schema) of the new connection object are different than those of the connection object from the previous context.

    2. the previous context is NOT overwritten and all non-persistent work tables remain in the session if the connection parameters are same for both the new connection object and the connection object from the previous context.

Usage

## S4 method for signature 'NativeDriver'
dbConnect(
  drv,
  host,
  uid,
  pwd = NULL,
  logmech = NULL,
  logdata = NULL,
  temp.database = NULL,
  ...
)

Arguments

drv

Specifies a NativeDriver object obtained from tdplyr::NativeDriver().

host

Specifies the fully qualified domain name or IP address of a Teradata Vantage System.

uid

Specifies the username to connect with.

pwd

Specifies the password for the connecting user.

logmech

Specifies the logon authentication method. Permitted values are TD2, LDAP, TDNEGO, KRB5 for Kerberos, and JWT.

logdata

Specifies additional data for the chosen logon authentication method. If logmech = JWT, then JWT token should be provided with the key 'jwt.token' in the named list of this argument.

temp.database

Specifies the database name in which temporary database object (table/view), for processing data, are created. Such objects are garbage collected at the end of the session.
Make sure the user has privilege to create objects in this database, otherwise the functions that create temporary objects will fail.
If this argument is not supplied, default database of the connection is used for temporary objects. To get the temporary database name, use function td_get_context().

...

Additional arguments as supported by the native driver. Currently, none supported.

Value

A "Teradata" connection object.

See Also

td_remove_context, td_create_context, td_get_context, td_set_context

Examples

# Establish a connection to Teradata Vantage using the dbConnect API and NativeDriver object.
# This will initialize the context based on the connection parameters, if the context does not
# exist.
con <- DBI::dbConnect(tdplyr::NativeDriver(), host = "<dbcname>", uid = "<tduser>",
                      pwd = "<tdpwd>")

# Establish a connection to Teradata Vantage using the dbConnect API and teradatasql
# TeradataDriver object.
# This will NOT initialize the context and td_get_context() function returns NULL if there is no
# previous context. One has to use td_set_context() function to initialize the context on
# TeradataDriver object.
con <- DBI::dbConnect(teradatasql::TeradataDriver(),
                      '{"host":"<dbcname>","user":"<tduser>","password":"<tdpwd>"}')