ConnectionContext

hanaml.ConnectionContext(
  dsn = "",
  username = "",
  password = "",
  odbc = TRUE,
  jdbcDriver = NULL,
  rodbc = FALSE,
  encrypt = NULL,
  validateCertificate = NULL,
  autocommit = FALSE,
  ...
)

Arguments

dsn

character
A registered data source name for ODBC or <host>:<port> for JDBC.

username

character
User name.

password

character
Password.

odbc

logical, optional
Whether to use ODBC or JDBC database connectivity. For ODBC connectivity, hana.ml.r supports two library "odbc"(recommended) and "RODBC".
Defaults to TRUE.

jdbcDriver

character, optional
Path to the JDBC driver. Only valid for JDBC.

rodbc

logical, optional
Whether to use library 'RODBC' for ODBC database connectivity. If TRUE, use RODBC. Else, use odbc. This parameter is only valid for using ODBC connectivity.
Defaults to FALSE.

encrypt

logical, optional
Whether or not to encrypt the connection.
Valid only for JDBC.

validateCertificate

logical, optional
Whehter or not to validate certifcate when connection to the server.
Valid only for JDBC.

autocommit

logical, optional
Whether or not setting a JDBC connection to autocommit mode.
Valid only for JDBC.
Defaults to FALSE.

...


Value

Object of R6Class with methods for ConnectionContext.

Details

Represents a connection to a SAP HANA system. ConnectionContext includes methods for creating DataFrames from data on SAP HANA. DataFrames are tied to a ConnectionContext, and are unusable once their ConnectionContext is closed.

Methods

close()

Closes the existing connection.
Usage: conn$close()

sql(sql)

Returns a DataFrame representing a query.

Usage: df <- conn$sql("SELECT T.A, T2.B FROM T, T2 WHERE T.C=T2.C")
Arguments:

  • sql, character: Sql Query.

Returns: DataFrame Dataframe for the query.

GetCurrentSchema()

Returns the name of current working schema in the database.

Usage: conn$GetCurrentSchema()
Returns: character Current schema name.

hana.version(getMajor=FALSE, ...)

Returns the version or major version of SAP HANA.

Usage: conn$hana.version()
Arguments:

  • getMajor, logical: if TRUE, return the major nubmer of SAP HANA version. Defaults to FALSE.

Returns: character or integer
The version of SAP HANA or major version if getMajor is TRUE.

table(table, schema = NULL)

Returns a DataFrame representing a table.

Usage: df1 <- conn$table("MY_TABLE")
df2 <- conn$table("MY_OTHER_TABLE", schema="MY_SCHEMA")
Arguments:

  • table, character: Table Name(without schema).

  • schema, character, optional: Schema name. Defaults to the ConnectionContext's current schema if not provided.

Returns: DataFrame DataFrame selecting data from that table.