Description
Use the td_create_context
function to establish a connection to
Teradata Vantage. The established connection will be set as the current
context for all subsequent analytic functions.
Note:
If a context already exists, this overwrites the previous context and removes all non-persistent work tables created by the analytic functions, even though the connection parameters
host
,uid
anddatabase
(i.e. default schema) are same for both the new connection object and the connection object from the previous context.When logmech argument (other than TD2 which is the current default logon mechanism) is used, you should setup the client with relevant security mechanisms.
tdplyr requires that the user has certain permissions on the user's default database or the initial default database specified using the "database" argument, or the temporary database when specified using "temp.database".
These permissions allow the user to:Create tables to save results of Vantage analytic functions.
Create views in the background for objects of class "tbl_teradata" based on query.
It is expected that the user has the required permissions to create these objects in the database that will be used.
For views based on Vantage Analytic Functions, additional permissions may be required, which can be granted using:
GRANT EXECUTE FUNCTION ON SYSLIB ... WITH GRANT OPTION
.
The access to the views created may also require issuing additional permissions depending on which database is used and which object the view being created is based on, which can be granted using:
GRANT SELECT ... WITH GRANT OPTION
.The "temp.database" and "database" parameters help determine which database is used by default to lookup for tables/views while creating objects of class "tbl_teradata" and which database is used to create all internal temporary objects, as shown in the table below.
Scenario tdplyr behaviour 1. Both "database" and "temp.database" are provided Internal temporary objects are created in "temp.database", and database table/view lookup is done from "database". 2. "database" is provided but "temp.database" is not Database table/view lookup and internal temporary objects are created in "database". 3. "temp.database" is provided but "database" is not Internal temporary objects are created in "temp.database", database table/view lookup from the users default database. 4. Neither "database" nor "temp.database" are provided Database table/view lookup and internal temporary objects are created in users default database.
Usage
td_create_context(
dsn = NULL,
host = NULL,
uid = NULL,
pwd = NULL,
tdWalletString = NULL,
database = NULL,
temp.database = NULL,
dType = "odbc",
logmech = NULL,
logdata = NULL,
log = 0,
...
)
Arguments
dsn |
(Deprecated) Optional argument.
Default Value: NULL |
host |
Optional argument. Required when "dType" is 'NATIVE'. |
uid |
Optional argument. |
pwd |
Optional argument.
|
tdWalletString |
(Deprecated) Optional argument.
Default Value: NULL |
database |
Optional argument.
Default Value: NULL |
temp.database |
Optional argument. |
dType |
Required argument. |
logmech |
Optional argument.
Permitted Values: TD2, LDAP, TDNEGO, KRB5 (for Kerberos) and JWT |
logdata |
Optional argument.
Default Value: NULL |
log |
Optional argument.
|
... |
Specifies the additional connection parameters that are passed
to Teradata SQL Driver for R. Please refer to
Connection Parameters
of the driver.
|
Value
Invisibly returns an object of class: DBIConnection
.
See Also
td_remove_context
, td_set_context
,
td_get_context
, dbConnect
Examples
# Note: The default database in the connection is used as the temporary
# database. For retrieving and removing context, check td_get_context()
# and td_remove_context() respectively.
# Example 1: Create a context using the Teradata SQL Driver. Note that the argument 'logmech' is
# not specified. Connection is established with default logon mechanism.
td_create_context(host = "<dbcname>", uid = "<tduser>", pwd = "<tdpwd>", dType = "NATIVE")
# Example 2: Create a context using the Teradata SQL Driver with various logon mechanisms.
# Connection using TD2: The Teradata 2(TD2) mechanism provides authentication using a Vantage
# database username and password.
td_create_context(host = "<dbcname>", uid = "<tduser>", pwd = "<tdpwd>", dType = "NATIVE",
logmech = "TD2")
# Connection using TDNEGO: TDNEGO is a security mechanism that automatically determines the
# actual mechanism required, based on policy, without user's involvement. The actual mechanism
# is determined by the TDGSS server configuration and the security policy's mechanism
# restrictions.
td_create_context(host = "<dbcname>", uid = "<tduser>", pwd = "<tdpwd>", dType = "NATIVE",
logmech = "TDNEGO")
# Connection using LDAP: LDAP is a directory-based mechanism. User logs on to a Vantage database
# with a directory username and password and is authenticated by the directory.
td_create_context(host = "<dbcname>", uid = "<tduser>", pwd = "<tdpwd>", dType = "NATIVE",
logmech = "LDAP")
# Connection using KRB5: KRB5 is a directory-based mechanism. User logs on to a Vantage database
# with a domain username and password and is authenticated by Kerberos (KRB5 or SPNEGO
# mechanism).
td_create_context(host = "<dbcname>", uid = "<tduser>", dType = "NATIVE", logmech = "KRB5")
# Connection using JWT: Using JWT token to connect to Vantage.
td_create_context(host = "<dbcname>", dType = "NATIVE", logmech = "JWT",
logdata = list(jwt.token="<token_value>"))
# Example 3: Create context using encrypted password and key passed to "pwd" parameter.
# The password should be specified in the format mentioned below:
# ENCRYPTED_PASSWORD(file:<PasswordEncryptionKeyFileName>, file:<EncryptedPasswordFileName>)
# The PasswordEncryptionKeyFileName specifies the name of a file that contains the password
# encryption key and associated information.
# The EncryptedPasswordFileName specifies the name of a file that contains the encrypted
# password and associated information.
# Each filename must be preceded by the 'file:' prefix. The PasswordEncryptionKeyFileName must
# be separated from the EncryptedPasswordFileName by a single comma.
td_create_context(host = "<dbcname>", uid = "<tduser>",
pwd = "ENCRYPTED_PASSWORD(file:PassKey.properties, file:EncPass.properties)",
dType = "NATIVE")
# Example 4: Create context using encrypted password in LDAP logon mechanism.
td_create_context(host = "<dbcname>", uid = "<tduser>",
pwd = "ENCRYPTED_PASSWORD(file:PassKey.properties, file:EncPass.properties)",
dType = "NATIVE", logmech = "LDAP")
# Example 5: Create context using 'ansi' mode with log value set to 8 and lob_support disabled.
td_create_context(host = "<dbcname>", uid = "<tduser>", pwd = "<tdpwd>", dType = "NATIVE",
tmode = 'ansi', log = 8, lob_support = FALSE)
# Example 6: Create context with 'database' parameter.
td_create_context(host = "<dbcname>", uid = "<tduser>", pwd = "<tdpwd>", dType = "NATIVE",
database = '<schema_name>')