Select: Select

Description Usage Arguments Details Value See Also Examples

View source: R/Select.R

Description

Convenience function for SELECT queries. One of the 6 table names can be given with optional WHERE statements. In case transactions, capital or personalAccounts is selected, a INNER JOIN with accounts will be done (2 joins for transactions).

Usage

1
2
Select(table, db, eq = NULL, ge = NULL, le = NULL, all_and = FALSE,
  enforce_foreign_keys = TRUE, check_query = FALSE)

Arguments

table

chr of table name, will automatically be INNER JOINed in case relation exists

db

chr full file name with path of database

eq

list (NULL) defining a condition with = (equal). Element name specifies column, value its value (see details)

ge

list (NULL) defining a condition with >= (greater-equal). Element name specifies column, value its value (see details)

le

list (NULL) defining a condition with <= (lesser-equal). Element name specifies column, value its value (see details)

all_and

bool (FALSE) whether all conditions are combined with AND

enforce_foreign_keys

bool (TRUE) whether to enforce rules on foreign keys

check_query

bool (FALSE) whether to just return the SQL query without actually sending it

Details

A WHERE condition can be added with arguments eq (equal), ge (greater-equal), le (lesser-equal). Conditions are given as list for the desired relation. The name of a list element defines a column and its value the value. Multiple ge and se conditions are combined by AND and eq conditions by OR. With all_and set to TRUE everything is combined with AND.

You can set check_query to TRUE to see the query.

Value

data.frame of table

See Also

Other SQLite handler functions: InsertBLOB, Insert, Intersect, SelectBLOB, UpdateBLOB, Update

Examples

1
2
3
4
5
6
7
8
db <- "db/test.db"
Create_testDB(db)
df <- Select(
  "transactions", 
  "db/test.db", 
  le = list(payor_id = 2), 
  eq = list(type = c("food", "purchase"))
)

mRcSchwering/abacus documentation built on May 21, 2019, 9:18 a.m.