dbReadTable-methods

0th

Percentile

Convenience functions for Importing/Exporting DBMS tables

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.

Keywords
methods, interface, database
Usage
dbReadTable(conn, name, row.names = "row_names", ...)
  dbWriteTable(conn, name, value, row.names = T, ...,
              overwrite = F, append = F)
  dbExistsTable(conn, name, ...)
  dbRemoveTable(conn, name, ...)
Arguments
conn
a database connection object.
name
a character string specifying a DBMS table name.
value
a data.frame (or coercible to data.frame).
row.names
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
overwrite
a logical specifying whether to overwrite an existing table or not. Its default is FALSE.
append
a logical specifying whether to append to an existing table in the DBMS. Its default is FALSE.
...
any optional arguments that the underlying database driver supports.
Value

  • dbReadTable returns a data.frame; all other functions return TRUE or FALSE denoting whether the operation was successful or not.

Note

The translation of identifiers between R/S-Plus and SQL is done through calls to make.names and make.db.names, but we cannot guarantee that the conversion is reversible. For details see make.db.names.

synopsis

dbReadTable(conn, name, ...) dbWriteTable(conn, name, value, ...) dbExistsTable(conn, name, ...) dbRemoveTable(conn, name, ...)

Side Effects

A DBMS statement is generated and remotely executed on a database engine; the result set it produces is fetched in its entirety. These operations may failed if the underlying database driver runs out of available connections and/or result sets, or the operation violates DBMS integrity constraints (e.g., attempting to write duplicate values on a field that's defined as a primary key).

dbWritetable slightly extend the semantics of assign to allow overwriting or appending to an existing table.

References

See the Database Interface definition document DBI.pdf in the base directory of this package or http://developer.r-project.org/db.

See Also

dbDriver, dbConnect, dbSendQuery, dbGetQuery, fetch, dbCommit, dbGetInfo, dbListTables, dbReadTable.

Aliases
  • dbReadTable
  • dbWriteTable
  • dbExistsTable
  • dbRemoveTable
  • dbReadTable-methods
  • dbWriteTable-methods
  • dbExistsTable-methods
  • dbRemoveTable-methods
  • dbReadTable,DBIConnection,character-method
  • dbWriteTable,DBIConnection,character,data.frame-method
  • dbExistsTable,DBIConnection,character-method
  • dbRemoveTable,DBIConnection,character-method
Examples
conn <- dbConnect("MySQL", group = "vitalAnalysis")
con2 <- dbConnect("Oracle", username = "user", password = "pwd")
if(dbExistsTable(con2, "fuel_frame")){
   fuel.frame <- dbReadTable(con2, "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)
}
Documentation reproduced from package DBI, version 0.1-10, License: GPL (version 2 or later)

Community examples

Looks like there are no examples yet.