Skip to contents

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 with aou_connect().

Value

a reference to a temporary table in the database with the data from df

Details

[Experimental]

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)
}