Become an expert in R — Interactive courses, Cheat Sheets, certificates and more!
Get Started for Free

dbReadTable

Convenience functions for importing/exporting DBMS tables


Description

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.

Usage

## S4 method for signature 'MySQLConnection,character'
dbReadTable(conn, name, row.names, check.names = TRUE, ...)

## S4 method for signature 'MySQLConnection'
dbListTables(conn, ...)

## S4 method for signature 'MySQLConnection,character'
dbExistsTable(conn, name, ...)

## S4 method for signature 'MySQLConnection,character'
dbRemoveTable(conn, name, ...)

## S4 method for signature 'MySQLConnection,character'
dbListFields(conn, name, ...)

Arguments

conn

a MySQLConnection object, produced by dbConnect

name

a character string specifying a table name.

row.names

A string or an index specifying the column in the DBMS table to use as row.names in the output data.frame. Defaults to using the row_names column if present. Set to NULL to never use row names.

check.names

If TRUE, the default, column names will be converted to valid R identifiers.

...

Unused, needed for compatiblity with generic.

Value

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

Note

Note that the data.frame returned by dbReadTable only has primitive data, e.g., it does not coerce character data to factors.

Examples

if (mysqlHasDefault()) {
con <- dbConnect(RMySQL::MySQL(), dbname = "test")

# By default, row names are written in a column to row_names, and
# automatically read back into the row.names()
dbWriteTable(con, "mtcars", mtcars[1:5, ], overwrite = TRUE)
dbReadTable(con, "mtcars")
dbReadTable(con, "mtcars", row.names = NULL)
}

RMySQL

Database Interface and 'MySQL' Driver for R

v0.10.21
GPL-2
Authors
Jeroen Ooms [aut, cre] (<https://orcid.org/0000-0002-4035-0289>), David James [aut], Saikat DebRoy [aut], Hadley Wickham [aut], Jeffrey Horner [aut], RStudio [cph]
Initial release

We don't support your browser anymore

Please choose more modern alternatives, such as Google Chrome or Mozilla Firefox.