db_tables_to_list | R Documentation |
tbl_dbi
objects from a DBIConnection
objectA convenience function that returns a list of tbl_dbi
objects from a DBIConnection
object, named as per the database table
names.
db_tables_to_list(conn)
conn |
A DBIConnection object, as returned by
|
See the introduction
to dbplyr vignette for getting started with databases and
dplyr
.
A named list of tbl_dbi
objects
# create an SQLite database in memory
con <- DBI::dbConnect(RSQLite::SQLite(), dbname = ":memory:")
# populate with tables
dplyr::copy_to(con, head(iris), "iris_head")
dplyr::copy_to(con, head(mtcars), "mtcars_head")
# create named list of tbl_dbi objects
db_tables <- db_tables_to_list(con)
# view tables
db_tables$iris_head
db_tables$mtcars_head
# to import to R, use dplyr::collect()
dplyr::collect(db_tables$iris_head)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.