Skip to contents

Execute a SQL query against an Oracle database and save the result as a Parquet file. If a cached file already exists, behaviour depends on the edstr_overwrite option (see edstr_config()).

Usage

edstr_import(
  query = NULL,
  head = NULL,
  lower = TRUE,
  user = NULL,
  password = NULL,
  connect_dir = getOption("edstr_connect_dir"),
  tns = "vlp",
  ...
)

Arguments

query

<character(1)> A SQL query string or a path to a .sql file. If NULL, the function errors.

head

<integer(1)> Optional. Limit the query to the first head rows (appends FETCH FIRST ... ROWS ONLY).

lower

<logical(1)> If TRUE (default), column names are converted to lowercase.

user

<character(1)> Database username.

password

<character(1)> Database password. Defaults to an interactive prompt via rstudioapi::askForPassword() (if available) or readline().

connect_dir

<character(1)> Path to the YAML connection configuration file read by config::get(). Defaults to getOption("edstr_connect_dir").

tns

<character(1)> TNS alias to select from the connection configuration (default "vlp").

...

Additional arguments passed to DatabaseConnector::connect().

Value

A data.frame with the imported data.

Details

Requires edstr_config() to be called first.

Examples

if (FALSE) { # \dontrun{
edstr_config(edstr_dirname = "output", edstr_filename = "my_study")

df <- edstr_import(
  query = "sql/my_query.sql",
  head = 100,
  user = "my_user"
)
} # }