Skip to content

Commit

Permalink
Merge pull request #3 from Oefenweb/fix-typos-cs-errors
Browse files Browse the repository at this point in the history
Fix typos & CS errors
  • Loading branch information
tersmitten authored Jan 23, 2025
2 parents 3a61e67 + ef0e862 commit 900d89a
Show file tree
Hide file tree
Showing 11 changed files with 88 additions and 8 deletions.
6 changes: 5 additions & 1 deletion .lintr
Original file line number Diff line number Diff line change
@@ -1 +1,5 @@
linters: with_defaults(line_length_linter(120), camel_case_linter = NULL)
linters: linters_with_defaults(
line_length_linter(120),
cyclocomp_linter = NULL,
seq_linter = NULL,
object_name_linter = NULL)
5 changes: 3 additions & 2 deletions DESCRIPTION
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ Remotes:
github::Oefenweb/r-dummy
Imports:
DBI (>= 0.5),
RMySQL (>= 0.10)
RoxygenNote: 7.0.2
RMySQL (>= 0.10),
glue
RoxygenNote: 7.3.2
Suggests: testthat
1 change: 1 addition & 0 deletions NAMESPACE
Original file line number Diff line number Diff line change
Expand Up @@ -3,3 +3,4 @@
export(close_connection)
export(close_connections)
export(connect)
export(get_query)
2 changes: 1 addition & 1 deletion R/close_connection.R
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#' Disconnects a given database connection.
#'
#' @param con A database connection (an object of class MySQLConnection).
#' @param con A DBIConnection object, as returned by dbConnect().
#' @return A logical vector of length 1, indicating success or failure.
#' @export
close_connection <- function(con) {
Expand Down
2 changes: 1 addition & 1 deletion R/connect.R
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
#'
#' @param dbname A database name, for example "oefenweb_nl_app" or "mathsgarden_com_app".
#' @param default.file A MySQL configuration file, containing login credentials.
#' @return A database connection (an object of class MySQLConnection).
#' @return A DBIConnection object, as returned by dbConnect().
#' @export
connect <- function(dbname = "oefenweb_nl_app", default.file = path.expand(file.path("~", ".my.cnf"))) {
return(DBI::dbConnect(RMySQL::MySQL(), dbname = dbname, default.file = default.file))
Expand Down
2 changes: 1 addition & 1 deletion R/oefenwebDatabase.R
Original file line number Diff line number Diff line change
Expand Up @@ -23,4 +23,4 @@
#'
#' @docType package
#' @name oefenwebDatabase
NULL
"_PACKAGE"
25 changes: 25 additions & 0 deletions R/query.R
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
#' Retrieve results from a query.
#'
#' Suppresses warnings and uses glue_sql for safety.
#'
#' @param ... [expressions] Unnamed arguments are taken to be expression string(s) to format.
#' Multiple inputs are concatenated together before formatting.
#' @param con A DBIConnection object, as returned by dbConnect().
#' @param params [list] Containing parameters called in SQL statement with \{params[[i]]\} or \{params[[j]]*\}
#' @return [data.frame] With as many rows as records were fetched and as many columns as fields in the result set.
#' @examples
#' \dontrun{
#' domain_ids <- 1:4
#' domain_name <- "Vermenigvuldigen"
#' query <- "SELECT `name` FROM `domains` WHERE `id` IN ({params[[1]]*}) AND `name` != {params[[2]]}"
#' params <- list(domain_ids, domain_name)
#' get_query(query, con = con, params = params)
#' }
#' @export
get_query <- function(..., con = con, params = NULL) {
return(
suppressWarnings(
DBI::dbGetQuery(con, glue::glue_sql(..., .con = con))
)
)
}
2 changes: 1 addition & 1 deletion man/close_connection.Rd

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

2 changes: 1 addition & 1 deletion man/connect.Rd

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

31 changes: 31 additions & 0 deletions man/get_query.Rd

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

18 changes: 18 additions & 0 deletions man/oefenwebDatabase.Rd

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

0 comments on commit 900d89a

Please sign in to comment.