dbManager               package:RMySQL               R Documentation

_I_n_s_t_a_n_t_i_a_t_e _a _d_a_t_a_b_a_s_e _m_a_n_a_g_e_r

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

     This function creates an object that allows you to connect to the
     Database Systems (DBMS)  specified in its argument.

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

     dbManager(obj, ...)

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

     obj: a character string specifying the DBMS, e.g., "MySQL", 
          "Oracle", "SQLite".  

    ... : additional parameters may be specified for the actual
          database engine. E.g., the Oracle implementation allows you
          to specify the maximum  number of open connection and a
          default maximum number of records  to be transferred from the
          database. See the individual manager functions for details,
          e.g., `Oracle', `MySQL', `SQLite'. 

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

     This object is a singleton, that is, if you invoke this function
     again, it will return the same initialized object.

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

     An object that extends `dbManager' and  `dbObjectId' in a
     database-specific manner. For instance `dbManager("Oracle")'
     produces an object of class `OraManager' and  is equivalent to
     using `Oracle'. Similarly `dbManager("Oracle")' produces an
     `OraManager' object and its equivalent to invoking `Oracle'.

     This object is required to create connections to one or several
     database engines.

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

     The R/S client part of the database communication is initialized,
     connecting to the database engine needs to be done through calls
     to `dbConnect'.

_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 Oracle instance and create one connection.
     > m <- dbManager("Oracle")
     > m
     OraManager 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, verbose = F)   
     OraManager id = (7269) 
       Max  connections: 16 
       Conn. processed: 1 
       Default records per fetch: 500 
       Open connections: 1 

     # 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
     OraResultSet 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

     # Extract meta-data information.  What Ora databases are there 
     # available on host "wyner"
     > getDatabases(m, host = "wyner")
        Database 
     1     mysql
     2      opto
     3      test
     4 iptraffic
     5     fraud

     > # What tables are there in the "opto" database? 
     > dbTables(m, dbname = "opto", host = "wyner")
       Tables in opto 
     1           PBCT
     2          PURGE
     3             WL
     4          liv25
     5          liv85

