#' Determine the length of a table
#'
#' Determine the length of a table, i.e. the number of records.
#'
#' @template db
#' @template name
#'
#' @export
db_length <- function(db, name) {
DBI::dbGetQuery(db, paste("SELECT COUNT(*) AS n FROM", name))$n
}
#' Wrapper to DBI::dbReadTable
#'
#' Get the table of \code{db} with name \code{name}.
#'
#' @template db
#' @template name
#'
#' @export
db_get_table <- function(db, name) {
fields <- c("rowid", DBI::dbListFields(db, name))
query <- paste(
"SELECT",
paste(fields, collapse = ", "),
"FROM",
name
)
DBI::dbGetQuery(
db,
query
)
}
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.