Creates a temporary table from a local data frame or tibble
Source:R/aou_temp_tables.R
aou_create_temp_table.Rd
Experimental function that builds a local tibble into an SQL
query and generates a temporary table. Larger tables will be broken up into
consequitive SQL queries; making nchar_batch
smaller can avoid errors but
will take longer. The table will only exist for the current connection
session and will need to be created again in a new session.
Usage
aou_create_temp_table(
data,
nchar_batch = 1e+06,
...,
con = getOption("aou.default.con")
)
Arguments
- data
A local dataframe (or tibble)
- nchar_batch
approximate number of characters to break up each SQL query
- ...
Not currently used
- con
Connection to the allofus SQL database. Defaults to
getOption("aou.default.con")
, which is created automatically withaou_connect()
.
Examples
if (FALSE) { # on_workbench()
con <- aou_connect()
df <- data.frame(
concept_id = c(
439331, 4290245, 42535816, 46269813,
2784565, 45765502, 434112, 4128031, 435640, 45876808
),
category = c(
"AB", "DELIV", "DELIV", "SA", "DELIV",
"LB", "DELIV", "DELIV", "PREG", "SA"
),
gest_value = c(NA, NA, NA, NA, NA, NA, NA, NA, 25, NA)
)
tmp_tbl <- aou_create_temp_table(df)
}