tbl.Pool: Use pool with dbplyr

View source: R/dbplyr.R

tbl.PoolR Documentation

Use pool with dbplyr

Description

Wrappers for key dplyr (and dbplyr) methods so that pool works seemlessly with dbplyr.

Usage

tbl.Pool(src, from, ..., vars = NULL)

copy_to.Pool(dest, df, name = NULL, overwrite = FALSE, temporary = TRUE, ...)

Arguments

src, dest

A dbPool.

from

Name table or dbplyr::sql() string.

...

Other arguments passed on to the individual methods

vars

A character vector of variable names in src. For expert use only.

df

A local data frame, a tbl_sql from same source, or a tbl_sql from another source. If from another source, all data must transition through R in one pass, so it is only suitable for transferring small amounts of data.

name

Name for remote table. Defaults to the name of df, if it's an identifier, otherwise uses a random name.

overwrite

If TRUE, will overwrite an existing table with name name. If FALSE, will throw an error if name already exists.

temporary

if TRUE, will create a temporary table that is local to this connection and will be automatically deleted when the connection expires

Examples

library(dplyr)

pool <- dbPool(RSQLite::SQLite())
# copy a table into the database
copy_to(pool, mtcars, "mtcars", temporary = FALSE)

# retrieve a table
mtcars_db <- tbl(pool, "mtcars")
mtcars_db
mtcars_db %>% select(mpg, cyl, disp)
mtcars_db %>% filter(cyl == 6) %>% collect()

poolClose(pool)

bborgesr/pool documentation built on Feb. 16, 2024, 2:48 a.m.