dbConnect               package:RMySQL               R Documentation

_C_r_e_a_t_e _a _c_o_n_n_e_c_t_i_o_n _t_o _a _R_D_B_M_S

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

     Connect to a RDBMS going through the appropriate authorization
     procedure

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

     dbConnect(mgr, ...)

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

     mgr: a `dbManager' object,  a character string specifying the
          RDBMS, e.g., "MySQL",  "Oracle", "Informix", or another
          `dbConnect' object. 

    ... : authorization arguments needed by the RDBMS instance; these
          typically include `user', `password', `dbname', `host',
          `port', etc. For details see the appropriate `dbManager'. 

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

     Some implementations (e.g., RS-MySQL, RS-Oracle) may allow you to
     have multiple connecions open, so you may invoke this  function
     repeatedly assigning its output to different objects.

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

     An object that extends `dbConnect' and  `dbObjectId' in a
     database-specific manner. For instance `dbConnect("MySQL")'
     produces an object of class `MySQLConnection'.

     This object is used to direct SQL commands to the database engine.

_S_i_d_e _E_f_f_e_c_t_s:

     A connection between R/S and the database server is established,
     and the R/S program becodes a client of the database engine.
     Typically the connections is through the TCP/IP protocol,  but
     this will depend on vendor-specific details.

_R_e_f_e_r_e_n_c_e_s:

     See the Omega Project for Statistical Computing at <URL:
     http://www.omegahat.org> for more details on the R/S database
     interface.

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

     On database managers:

     `dbManager' `MySQL' `load' `unload'

     On connections, SQL statements and resultSets:

     `dbExecStatement' `dbExec' `fetch' `quickSQL'

     On transaction management:

     `commit' `rollback'

     On meta-data:

     `describe' `getVersion' `getDatabases' `getTables' `getFields'
     `getCurrentDatabase' `getTableIndices' `getException'
     `getStatement' `hasCompleted' `getRowCount' `getAffectedRows'
     `getNullOk' `getInfo'

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

     # create a MySQL instance and create one connection.
     > m <- dbManager("MySQL")
     > m
     MySQLManager id = (7269) 

     # open the connection using user, passsword, etc., as
     # specified in the file \file{\$HOME/.my.cnf}
     > con <- dbConnect(m)    

     # Let's look at the status of the manager
     > describe(m)
     MySQLManager id = (7269) 
       Max  connections: 16 
       Conn. processed: 1 
       Default records per fetch: 500 

     # Run an SQL statement by creating first a resultSet object
     > rs <- dbExecStatement(con, 
              statement = "SELECT w.laser_id, w.wavelength, p.cut_off 
                           FROM WL w, PURGE P
                           WHERE w.laser_id = p.laser_id
                           SORT BY w.laser_id")
     > rs
     MySQLResultSet id = (12629,1,3)

     # we now fetch records from the restulSet into a data.frame
     > data <- fetch(rs, n = -1)   # extract all rows
     > dim(data)
     [1] 1779  18

