
Returns the contents of a database table given by name as a data frame.
# S4 method for SQLiteConnection,character
dbReadTable(conn, name, ...,
row.names = NA, check.names = TRUE, select.cols = "*")
a '>SQLiteConnection
object, produced by
DBI::dbConnect()
a character string specifying a table name. SQLite table names
are not case sensitive, e.g., table names ABC
and abc
are considered equal.
Needed for compatibility with generic. Otherwise ignored.
Either TRUE
, FALSE
, NA
or a string.
If TRUE
, always translate row names to a column called "row_names".
If FALSE
, never translate row names. If NA
, translate
rownames only if they're a character vector.
A string is equivalent to TRUE
, but allows you to override the
default name.
For backward compatibility, NULL
is equivalent to FALSE
.
If TRUE
, the default, column names will be
converted to valid R identifiers.
A SQL expression (in the form of a character vector of
length 1) giving the columns to select. E.g. "*"
selects all columns,
"x, y, z"
selects three columns named as listed.
A data frame.
Note that the data frame returned by dbReadTable()
only has
primitive data, e.g., it does not coerce character data to factors.
The corresponding generic function DBI::dbReadTable()
.
# NOT RUN {
library(DBI)
db <- RSQLite::datasetsDb()
dbReadTable(db, "mtcars")
dbReadTable(db, "mtcars", row.names = FALSE)
dbReadTable(db, "mtcars", select.cols = "cyl, gear")
dbReadTable(db, "mtcars", select.cols = "row_names, cyl, gear")
dbDisconnect(db)
# }
Run the code above in your browser using DataLab