-
Notifications
You must be signed in to change notification settings - Fork 19
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #301 from ncss-tech/esagg
get_SDA_coecoclass: add `method="all"`
- Loading branch information
Showing
5 changed files
with
225 additions
and
10 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,7 +1,7 @@ | ||
Package: soilDB | ||
Type: Package | ||
Title: Soil Database Interface | ||
Version: 2.7.9 | ||
Version: 2.7.9.9000 | ||
Authors@R: c(person(given="Dylan", family="Beaudette", role = c("aut"), email = "[email protected]"), | ||
person(given="Jay", family="Skovlin", role = c("aut")), | ||
person(given="Stephen", family="Roecker", role = c("aut")), | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
#' Query arbitrary data sources that use the SSURGO data model | ||
#' | ||
#' This is a simple wrapper function allowing queries to be passed to a variety of database drivers. It is assumed the database generally follows the SSURGO schema, regardless of the driver being used. | ||
#' | ||
#' @param x An SQL query. If `dsn` is NULL `x` is in T-SQL dialect. If `dsn` is a _character_ (file path), the SQLite dialect is used. If `dsn` is a `DBIConnection`, any SQL dialect compatible with the DBI source can be used. | ||
#' @param dsn Default: `NULL` uses Soil Data Access remote data source via REST API. Alternately `dsn` may be a _character_ file path to an SQLite database, or a `DBIConnection` that has already been created. | ||
#' | ||
#' @details No processing of the query string is performed by this function, so all values of `x` must be adjusted according to the value of `dsn`. | ||
#' | ||
#' @return A _data.frame_, or _try-error_ on error | ||
#' @noRd | ||
.SSURGO_query <- function(x, dsn = NULL) { | ||
if (is.null(dsn)) { | ||
return(SDA_query(x)) | ||
} else { | ||
if (inherits(dsn, 'DBIConnection')) { | ||
return(DBI::dbGetQuery(con, x)) | ||
} else if (file.exists(dsn)) { | ||
if (requireNamespace("RSQLite")) { | ||
con <- try(RSQLite::dbConnect(RSQLite::SQLite(), dsn)) | ||
on.exit(DBI::dbDisconnect(con), add = TRUE) | ||
if (!inherits(con, 'try-error')) { | ||
return(RSQLite::dbGetQuery(con, x)) | ||
} else { | ||
return(invisible(con)) | ||
} | ||
} | ||
} else { | ||
stop("Invalid data source name: ", dsn, call. = FALSE) | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.