dbReadTable-methods          package:RMySQL          R Documentation

_C_o_n_v_e_n_i_e_n_c_e _f_u_n_c_t_i_o_n_s _f_o_r _I_m_p_o_r_t_i_n_g/_E_x_p_o_r_t_i_n_g _D_B_M_S _t_a_b_l_e_s

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

     These functions mimic their R/S-Plus counterpart  'get', 'assign',
     'exists',  'remove', and 'objects', except that they generate code
     that gets remotely executed in a database engine.

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

     A 'data.frame' in the case of 'dbReadTable'; otherwise a logical 
     indicating whether the operation was successful.

_M_e_t_h_o_d_s:

     _c_o_n_n an 'MySQLConnection' database connection object.

     _n_a_m_e a character string specifying a table name.

     _v_a_l_u_e a data.frame (or coercible to data.frame).

     _r_o_w._n_a_m_e_s in the case of 'dbReadTable', this argument can be a
          string or an index specifying the column in the DBMS table to
          be used as  'row.names' in the output data.frame (a 'NULL',
          '""', or 0  specifies that no column should be used as
          'row.names' in the output).

          In the case of 'dbWriteTable', this argument should be a
          logical specifying whether the 'row.names' should be output
          to the output DBMS table; if 'TRUE', an extra field whose
          name will be  whatever the R/S-Plus identifier '"row.names"'
          maps to the DBMS (see 'make.db.names').

     _o_v_e_r_w_r_i_t_e a logical specifying whether to overwrite an existing
          table or not.  Its default is 'FALSE'.

     _a_p_p_e_n_d a logical specifying whether to append to an existing table
          in the DBMS.  Its default is 'FALSE'.

     _a_l_l_o_w._k_e_y_w_o_r_d_s 'dbWriteTable' accepts a logical 'allow.keywords' 
          to allow or prevent MySQL reserved identifiers to be used as 
          column names. By default it is 'FALSE'.

_N_o_t_e:

     Note that data.frames are only approximately analogous to tables
     (relations) in relational DBMS, and thus you should not expect
     complete agreement in their semantics.  Tables in RDBMS are best
     thought of as _relations_ with a number of constraints imposed by
     the relational database model, and data.frames, with their roots
     in statistical modeling, as self-contained "sequence of
     observations on some chosen variables" (Chambers and Hastie
     (1992), p.46).  In particular the 'data.frame' returned by
     'dbReadTable' only has primitive data, e.g., it does not coerce
     character data to factors. Also, column names in a data.frame are
     _not_ guaranteed to be  equal to the column names in a MySQL
     exported/imported table (e.g., by default MySQL reserved
     identifiers may not be used as column names - and with 218
     keywords like '"BEFORE"', '"DESC"', and '"FROM"' the likelihood of
     name conflicts is not small.) Use 'isSQLKeyword(con,
     names(value))' to check whether the data.frame names in 'value'
     coincide with  MySQL reserver words.

     MySQL table names are _not_ case sensitive, e.g., table names
     'ABC' and 'abc' are considered equal.

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

     See the Database Interface definition document 'DBI.pdf' in the
     base directory of this package or <URL:
     http://stat.bell-labs.com/RS-DBI>.

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

     'MySQL', 'isSQLKeyword', 'dbDriver', 'dbConnect', 'dbSendQuery',
     'dbGetQuery', 'fetch', 'dbCommit', 'dbGetInfo', 'dbListTables',
     'dbReadTable'.

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

     ## Not run: 
     conn <- dbConnect("MySQL", group = "wireless")
     if(dbExistsTable(con, "fuel_frame")){
        dbRemoveTable(conn, "fuel_frame")
        dbWriteTable(conn, "fuel_frame", fuel.frame)
     }
     if(dbExistsTable(conn, "RESULTS")){
        dbWriteTable(conn, "RESULTS", results2000, append = T)
     else
        dbWriteTable(conn, "RESULTS", results2000)
     }
     ## End(Not run)

