lazysql: Lazy SQL Programming
- CRAN: http://cran.r-project.org/web/packages/lazysql/index.html
- GitHub: https://github.com/UweBlock/lazysql
> library(lazysql)
バージョン: 0.1.3
関数名 | 概略 |
---|---|
date_between |
Create SQL string to select date between two given dates |
in_condition |
Create SQL string to select values included in a set of given values |
lazysql |
Lazy SQL programming |
natural_key |
Create SQL string for joining on matching natural keys |
valid_identifier_regex |
Regex pattern to validate SQL identifier names |
date_between
> date_between("STD_1", c(as.Date("2016-02-22"), as.Date("2016-02-11"))) %>%
+ paste("select * from TEST_TABLE where", .)
[1] "select * from TEST_TABLE where STD_1 between to_date('2016-02-11', 'yyyy-mm-dd') and to_date('2016-02-22', 'yyyy-mm-dd')"
in_condition
> in_condition("COL_1", 1:3)
[1] "COL_1 in (1, 2, 3)"
> in_condition("COL_1", 1:3, "not")
[1] "COL_1 not in (1, 2, 3)"
> in_condition("COL_1", LETTERS[2:3])
[1] "COL_1 in ('B', 'C')"
natural_key
> (sql_expr <- natural_key(c("TAB1", "tab_2"),c("COL1", "col_2")))
[1] "TAB1.COL1 = tab_2.COL1 and TAB1.col_2 = tab_2.col_2"