Skip to content

Commit

Permalink
Package name RSQL instead of rsql. Checking 0.1.1
Browse files Browse the repository at this point in the history
  • Loading branch information
kenarab committed Jan 8, 2020
1 parent 12826c2 commit 4dfd1b1
Show file tree
Hide file tree
Showing 8 changed files with 15 additions and 18 deletions.
2 changes: 0 additions & 2 deletions NAMESPACE
Expand Up @@ -5,8 +5,6 @@ export(createRSQL)
export(getMtcarsdbPath)
export(getPackageDir)
export(parse_where_clause)
export(sql_retrieve)
export(sql_retrieve_insert)
import(DBI)
import(R6)
import(lgr)
Expand Down
7 changes: 3 additions & 4 deletions R/sql-lib.R
Expand Up @@ -13,6 +13,7 @@
#' @description
#' This class is intended to simplify SQL commands.
#' @examples
#' library(RSQL)
#' db.name <- getMtcarsdbPath(copy = TRUE)
#' rsql <- createRSQL(drv = RSQLite::SQLite(), dbname = db.name)
#' where_values_df <- data.frame(carb = 8, stringsAsFactors = FALSE)
Expand All @@ -35,7 +36,7 @@
#' where_values = where_values_df)
#' mtcars.observed <- rsql$execute_select(select_sql)
#' mtcars.observed
#' å
#'
#' @export
#' @importFrom R6 R6Class
RSQL.class <- R6::R6Class("RSQL", public = list(
Expand Down Expand Up @@ -821,7 +822,6 @@ df_verify <- function(dataframe, columns) {
#' @param fields The fields (Not used. Included for compatibility)
#' @param values The values (Not used. Included for compatibility)
#' @param dbconn The database connection
#' @export
sql_retrieve <- function(table, fields_uk = names(values_uk), values_uk,
fields = names(values), values = NULL,
field_id = "id", dbconn = NULL) {
Expand Down Expand Up @@ -853,7 +853,6 @@ sql_retrieve <- function(table, fields_uk = names(values_uk), values_uk,
#' @param values The values
#' @param field_id The field of the serial id
#' @param dbconn The database connection
#' @export
sql_retrieve_insert <- function(table, fields_uk = names(values_uk), values_uk,
fields = names(values), values = NULL,
field_id = "id", dbconn = NULL) {
Expand Down Expand Up @@ -1033,7 +1032,7 @@ parse_where_clause <- function(where_clause_list = c()) {
#' Gets the path of package data.
#' @export
getPackageDir <- function(){
home.dir <- find.package("rsql", lib.loc = NULL, quiet = TRUE)
home.dir <- find.package("RSQL", lib.loc = NULL, quiet = TRUE)
data.subdir <- file.path("inst", "extdata")
if (!dir.exists(file.path(home.dir, data.subdir)))
data.subdir <- "extdata"
Expand Down
2 changes: 1 addition & 1 deletion R/zzz.R
Expand Up @@ -3,7 +3,7 @@
#' A package to work with SQL datasources in a simple manner
#'
#' @docType package
#' @name rsql
#' @name RSQL
#' @import R6 lgr DBI
#' @importFrom utils str
#' @author Alejandro Baranek <abaranek@dc.uba.ar>, Leonardo Javier Belen <leobelen@gmail.com>
Expand Down
3 changes: 2 additions & 1 deletion man/RSQL.class.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions man/rsql.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

5 changes: 3 additions & 2 deletions tests/testthat.R
@@ -1,13 +1,14 @@
library(testthat)
library(DBI)
library(RSQLite)
library(rsql)
library(RSQL)
library(lgr)
library(dplyr)

log.levels <- lgr::get_log_levels()

lgr$set_threshold(log.levels["debug"])



test_check("rsql")
test_check("RSQL")
2 changes: 0 additions & 2 deletions tests/testthat/test_sql_lib.R
@@ -1,5 +1,3 @@
# TODO remove from here
library(dplyr)

db.name <- getMtcarsdbPath()
rsql <- createRSQL(drv = RSQLite::SQLite(), dbname = db.name)
Expand Down
8 changes: 4 additions & 4 deletions vignettes/rsql.Rmd
Expand Up @@ -13,14 +13,14 @@ In order to use rsql, a RSQL object has to be initialized, indicating all inform

```
library(RSQLite)
sql <- rsql(drv=RSQLite::SQLite(), dbname = "mtcars")
sql <- createRSQL(drv=RSQLite::SQLite(), dbname = "mtcars")
```

On success, it is possible to use the object to produce queries and execute them to retrieve information. Returned query sets can be in data.frame format for easy integration with R scripts.

```
library(RSQLite)
sql <- rsql(drv=RSQLite::SQLite(), dbname = "mtcars")
sql <- createRSQL(drv=RSQLite::SQLite(), dbname = "mtcars")
query.sql <- sql$generate_select(c("mpg","cyl","disp","hp","drat","wt","qsec","vs","am","gear","carb"),
"mtcars")
mtcars.df <- sql$execute_select(query.sql)
Expand All @@ -30,7 +30,7 @@ Also, rsql allows to insert or delete records as easily.

```
library(RSQLite)
sql <- rsql(drv=RSQLite::SQLite(), dbname = "mtcars")
sql <- createRSQL(drv=RSQLite::SQLite(), dbname = "mtcars")
insert.fields <- c("mpg","cyl","disp","hp","drat","wt","qsec","vs","am","gear","carb")
insert.data <- data.frame(1,2,3,4,5,6,7,8,9,10,11)
insert.sql <- sql$generate_insert("mtcars",insert.fields,
Expand All @@ -44,6 +44,6 @@ Finally, once the connection is not longer needed, it has to be expressly discon

```
library(RSQLite)
sql <- rsql(drv=RSQLite::SQLite(), dbname = "mtcars")
sql <- createRSQL(drv=RSQLite::SQLite(), dbname = "mtcars")
sql$disconnect()
```

0 comments on commit 4dfd1b1

Please sign in to comment.