odbcConnect              package:RODBC              R Documentation

_O_D_B_C _O_p_e_n _C_o_n_n_e_c_t_i_o_n_s

_D_e_s_c_r_i_p_t_i_o_n:

     Open connections to ODBC databases.

_U_s_a_g_e:

     odbcConnect(dsn, uid = "", pwd = "", case = "nochange",
                 believeNRows = TRUE)
     odbcDriverConnect(connection, case = "nochange", believeNRows = TRUE)
     odbcReConnect(channel, case, believeNRows)

_A_r_g_u_m_e_n_t_s:

     dsn: character string. A registered data source name.

uid, pwd: UID and password for authentication (if required).

connection: character string. See your ODBC documentation for the
          format.

    case: Controls case changes for different RDBMS engines.

 channel: RODBC connection object returned by `odbcConnect'.

believeNRows: logical.  Is the number of rows returned by the ODBC
          connection believable?  Not true for Oracle, apparently.

_D_e_t_a_i_l_s:

     `odbcConnect' establishes a connection to the dsn, and
     `odbcDriverConnect' allows a more flexible specification via a
     connection string.  `odbcConnect' uses the connection string
     `"DSN=dsn;UID=uid;PWD=pwd"'.  See the examples for other uses of
     connection strings.

     For databases that translate table and column names the case must
     be set as appropriate.  Allowable values are `"nochange"',
     `"toupper"' and `"tolower"' as well as the names of databases
     where the behaviour is known to us (currently `"mysql"' (which
     maps to lower case on Windows but not on Linux), `"postgresql"'
     (lower), `"oracle"' (upper) and `"msaccess"') (nochange).

     Function `odbcReConnect' re-connects to a database using the
     settings of an existing (and presumably now closed) channel
     object. Arguments `case' and `believeNRows' are taken from the
     object, but can be overridden by supplying those arguments.

_V_a_l_u_e:

     A non-negative integer which is used as handle if no error
     occurred, -1 otherwise. A successful return has class `"RODBC"',
     and attribute `"connection.string"' giving the full ODBC
     connection string.

_A_u_t_h_o_r(_s):

     Michael Lapsley, Brian Ripley

_S_e_e _A_l_s_o:

     `odbcClose', `sqlQuery', `odbcGetInfo'

_E_x_a_m_p_l_e_s:

     # MySQL
     channel <- odbcConnect("test", uid="ripley", pwd="secret")
     # PostgreSQL
     channel <- odbcConnect("pg", uid="ripley", pwd="secret", case="postgresql")

     # re-connection
     odbcCloseAll()
     channel <- odbcReConnect(channel) # must re-assign as the data may well change

