knitr::opts_chunk$set( collapse = TRUE, dpi=200, comment = "#>", fig.path = "man/figures/README-", out.width = "100%" )
Allows the user to generate and execute select, insert, update and delete 'SQL' queries the underlying database without having to explicitly write 'SQL' code.
| Release | Usage | Development |
|:--------|:------|:------------|
|| |
|
|
| |
|
|||
|
install.packages("RSQL")
Install the R package using the following commands on the R console:
devtools::install_github("rOpenStats/RSQL", build_opts = NULL)
To get started execute the following commands:
# 0. Load libraries library(RSQL)
# 1. RSQL db.name <- getMtcarsdbPath() rsql <- createRSQL(drv = RSQLite::SQLite(), dbname = db.name) query_sql <- rsql$gen_select( select_fields = c("*"), table = "mtcars") query_sql <- rsql$gen_select( select_fields = c("mpg", "cyl", "disp", "hp", "drat", "wt", "qsec", "vs", "am"), table = "mtcars", where_fields = "gear", where_values = 4) query_sql rsql$execute_select(query_sql)
update_sql <- rsql$gen_update( update_fields = c("vs"), values = 1, table = "mtcars", where_fields = "gear", where_values = 4) update_sql rsql$execute_update(update_sql) rsql$execute_select(query_sql)
insert.df <- c(4, rep(99, 9)) names(insert.df) <- c("gear", "mpg", "cyl", "disp", "hp", "drat", "wt", "qsec", "vs", "am") insert.df <- as.data.frame(t(insert.df)) insert_sql <- rsql$gen_insert( values = insert.df, table = "mtcars") rsql$execute_insert(insert_sql) rsql$execute_select(query_sql)
Please note that the 'RSQL' project is released with a Contributor Code of Conduct. By contributing to this project, you agree to abide by its terms.
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.