rquery: RQuery

Description Usage Arguments Value Examples

Description

Query the database efficiently and cache data appropriately in subdirectories

Usage

1
2
rquery(sql = NULL, name, subs = NULL, data.dir = "data",
  sql.dir = "sql", subs.dir = "subs", daily = FALSE, overwrite = FALSE)

Arguments

sql

SQL query to run

name

name of query

subs

One row data frame whose column names are the substrings to replace, and whose values are the strings to replace them with.

data.dir

Query results directory. Stores the results of the SQL queries as RDS files.

sql.dir

SQL query directory. Stores all the SQL used. If subs were provided, it saves the query before the subs were inserted.

subs.dir

Subs directory. Stores all the individual subs for each query as a data frame.

daily

Boolean to indicate whether to force a rerun of the query on first execution each day.

overwrite

Boolean to indicate whether to force a rerun of the query.

Value

Data frame of the query results

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
sys.setenv(
  'db_dsn' = 'mydb',
  'db_username' = 'myuser',
  'db_password' = 'password'
)

sql <- "select 1 as a from dual where 1 = XnumberX"
subs <- data.frame('XnumberX' = 1)

rquery(sql, 'myquery', subs)

ndesmo/rquery documentation built on May 7, 2019, 9:43 p.m.