memdb_frame() works like tibble::tibble(), but instead of creating a new data frame in R, it creates a table in src_memdb().

memdb_frame(..., .name = unique_table_name())

tbl_memdb(df, name = deparse(substitute(df)))

src_memdb()

Arguments

...

A set of name-value pairs. Arguments are evaluated sequentially, so you can refer to previously created elements. These arguments are processed with rlang::quos() and support unquote via !! and unquote-splice via !!!. Use := to create columns that start with a dot.

df

Data frame to copy

name, .name

Name of table in database: defaults to a random name that's unlikely to conflict with an existing table.

Examples

library(dplyr) df <- memdb_frame(x = runif(100), y = runif(100)) df %>% arrange(x)
#> # Source: table<dbplyr_005> [?? x 2] #> # Database: sqlite 3.22.0 [:memory:] #> # Ordered by: x #> x y #> <dbl> <dbl> #> 1 0.00740 0.418 #> 2 0.0201 0.751 #> 3 0.0280 0.383 #> 4 0.0281 0.00450 #> 5 0.0312 0.165 #> 6 0.0342 0.0115 #> 7 0.0514 0.403 #> 8 0.0586 0.164 #> 9 0.0637 0.775 #> 10 0.0652 0.464 #> # … with more rows
df %>% arrange(x) %>% show_query()
#> <SQL> #> SELECT * #> FROM `dbplyr_005` #> ORDER BY `x`
mtcars_db <- tbl_memdb(mtcars)
#> Error: Table `mtcars` exists in database, and both overwrite and append are FALSE
mtcars_db %>% count(cyl) %>% show_query()
#> Error in eval(lhs, parent, parent): object 'mtcars_db' not found