% Generated by roxygen2: do not edit by hand
% Please edit documentation in R/memdb.R
\name{memdb}
\alias{memdb}
\alias{memdb_frame}
\alias{local_memdb_frame}
\title{A temporary in-memory database}
\usage{
memdb()

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

local_memdb_frame(.name = unique_table_name(), ..., frame = caller_env())
}
\arguments{
\item{.name}{Name of table in database: defaults to a random name that's
unlikely to conflict with an existing table.}

\item{...}{<\code{\link[rlang:dyn-dots]{dynamic-dots}}>
A set of name-value pairs. These arguments are
processed with \code{\link[rlang:defusing-advanced]{rlang::quos()}} and support unquote via \code{\link[rlang:injection-operator]{rlang::!!}} and
unquote-splice via \code{\link[rlang:splice-operator]{rlang::!!!}}. Use \verb{:=} to create columns that start with a dot.

Arguments are evaluated sequentially.
You can refer to previously created elements directly or using the \link[rlang:dot-data]{rlang::.data}
pronoun.
To refer explicitly to objects in the calling environment, use \code{\link[rlang:injection-operator]{rlang::!!}} or
\link[rlang:dot-data]{rlang::.env}, e.g. \code{!!.data} or \code{.env$.data} for the special case of an object
named \code{.data}.}

\item{frame}{The created table is bound to this execution frame and will
be deleted when it ends. For expert use only.}
}
\description{
\code{memdb()} creates a temporary in-memory database that disappears when the
R session ends. It's a convenient way to learn about and experiment with
dbplyr without having to connect to a "real" database.

\code{memdb_frame()} works like \code{\link[tibble:tibble]{tibble::tibble()}}, but instead of creating a new
data frame in R, it creates a table in \code{memdb()}. \code{local_memdb_frame()}
is like \code{memdb_frame()} but the table will be automatically deleted when
the current scope ends. It's useful for tests. But beware: this function
will overwrite an existing table of the same name.
}
\examples{
library(dplyr)

# use memdb_frame() to create a new database table
df <- memdb_frame(x = runif(100), y = runif(100))
df |> arrange(x)
df |> arrange(x) |> show_query()

# Use memdb() + copy_to() to copy an existing data frame
iris_db <- copy_to(memdb(), iris)
iris_db
}
