Connection to Netezza

Before you can work with the Netezza system, you must establish a connection. This section contains a brief overview of functions that allow you to connect to Netezza.

Functions for connecting

The two most frequently used functions are:
  • nzConnect()
  • nzConnectDSN()
These functions pass user-supplied credentials or a predefined Database Source Name (DSN) string respectively. If called with the default value of the verbose parameter, they also output the R version and the Netezza R Library-related packages that are installed on the Netezza system.
#load nzr package
library(nzr)
# connect to a Netezza database "mm" on the "TT4-R040"
machine nzConnect("user", "password", "TT4-R040", "mm")
#Installed version of ' r_ae ' cartridge: 3.0.1.35826
#On the spus: R 3.5.1
#On the host: R 3.5.1
#
# or:
nzConnectDSN('NetezzaSQL', verbose=FALSE)

Functions for stopping connections

To stop a connection, you must call the nzDisconnect() function, which removes the hidden variable.

Functions for testing connections

Two other functions that are useful for testing connections are
nzCheckConnection()
Throws an error if a connection is not open
nzIsConnected()
Returns a boolean value that indicates whether there is a connection to the Netezza system.

Conncting

Either nzConnect() or nzConnectDSN() must be called before any other Netezza R library function can be called because a connection function sets a hidden variable, the existence of which is checked in other Netezza R library functions. Before connecting to a different machine, an existing connection must be stopped by using nzDisconnect(), or by setting the force argument in nzConnect() to TRUE.

The function signature with default arguments is:
nzConnect(user, password, machine, database, force = FALSE, queryTimeout =
0, loginTimeout = 0, verbose = TRUE)
nzConnectDSN(dsn, force = FALSE, verbose = TRUE)
Where:
user
Specifies the name of a database user, given as a string.
password
Specifies the password of a database user, given as a string.
machine
Specifies the name or IP address of a Netezza machine, given as a string.
database
Specifies the name of a database, given as a string.
force
Optional. Specifies the option to force a connection; the default value is FALSE.
queryTimeout
Optional. Indicates the timeout for a query; the default value is 0, which means “no timeout”.
loginTimeout
Optional. Indicates the login timeout; the default value is 0, which means “no timeout”.
verbose
Optional. Indicates the verbose mode.
dsn
Specifies the DSN string as defined in the local ODBC configuration.