metaData               package:RMySQL               R Documentation

_R/_S _d_a_t_a_b_a_s_e _i_n_t_e_r_f_a_c_e _m_e_t_a-_d_a_t_a

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

     Extract meta-data associated with various objects

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

     getInfo(dbObject, what)      # meta-data for any dbObject
     getConnection(what, ...)

     getConnections(mgr)          # meta-data for dbManager objects
     getDatabases(obj, ...)       
     getTables(obj, dbname, row.names, ...)
     getVersion(obj, ...)
     getTableIndices(res, table, dbname, ...)

     getCurrentDatabase(con)      # meta-data for dbConnection objects
     getException(con, ...)
     getResultSets(con, ...)
     getTableFields(res, table, dbname, ...)

     getStatement(res)             # meta-data for dbResultSet objects
     getFields(res, ...)
     hasCompleted(res, ...)
     getRowCount(res, ...)
     getRowsAffected(res, ...)
     getNullOk(res, ...)

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

dbObject: any object that implements some functionality in the R/S
          interface to databases (e.g., `dbManager', `dbConnection',
          `dbResultSet').

     mgr: refers to a `dbManager' object.

     con: refers to a `dbConnection' object.

      rs: refers to a `dbResultSet' object.

  dbname: refers to a database name (instance) on the server.

   table: refers to a table name in either the current database or  in
          `dbname'.

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

     These functions implement a minimal set of more or less obvious
     meta-data describing the most important aspects of the R/S to
     RDBMS interface.

     The `getInfo' works very similarly  to the function `options'  in
     that it attempts to  extract what the user may request, possibly
     NULL if it can't locate the specific piece of meta-data.

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

     either a character vector or a named list of meta-data objects.

_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:

     m <- dbManager(dbms)

     # Extract meta-data information.  What MySQL 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 Oracle "opto" database? 

     > dbTables(m, dbname = "opto", host = "wyner")
       Tables in opto 
     1           PBCT
     2          PURGE
     3             WL
     4          liv25
     5          liv85

     # let's look at some result set meta-data

     > con <- dbConnect(m)
     > rs <- dbExecStatement(con, query.sql)

     > getStatement(rs)
     [1] "show tables"

     > hasCompleted(rs)
     [1] 0

     > getRowCount(rs)
     [1] 3

     > info <- getInfo(rs)
     > names(info)
     [1] "statement"     "isSelect"        "rowsAffected"     
     [4] "rowCount"     "completed"    "fieldDescription"
     > getStatement(rs)
     [1] "show tables"

     # the following are pieces of meta-data associated with 
     # the R/S DBI implementation, versions for the various pieces 
     # of software (client, server, interface), etc.

     # dbManager object

     > names(getInfo(m))  
     [1] "connectionIds"     "fetch_default_rec"
     [3] "managerId"         "length"           
     [5] "num_con"           "counter"          
     [7] "clientVersion"    

     #  dbConnection object

     > names(getInfo(con))
     [1] "host"            "user"           
     [3] "dbname"          "conType"        
     [5] "serverVersion"   "protocolVersion"
     [7] "threadId"        "rsId"           

     # resultSet object

     > names(getInfo(rs)) 
     [1] "statement"        "isSelect"        
     [3] "rowsAffected"     "rowCount"        
     [5] "completed"        "fieldDescription"

