#' Get the src_sqlite for a receiver or tag database
#'
#' Receiver database files have names like "SG-1234BBBK06EA.motus" or
#' "Lotek-12345.motus", and project database files have names like
#' "project-52.motus".
#'
#' @param recv receiver serial number
#'
#' @param proj integer motus project number
#' exactly one of `proj` or `recv` must be specified.
#'
#' @param create Is this a new database? Default: FALSE.
#' Same semantics as for src_sqlite()'s parameter of the same
#' name: the DB must already exist unless you specify \code{create=TRUE}
#'
#' @param dbDir path to folder with existing receiver databases
#' Default: \code{Motus$dbDir}, which is set to the current folder
#' by \code{getwd()} when this library is loaded.
#'
#' @return a src_sqlite for the receiver; if the receiver is new, this database
#' will be empty, but have the correct schema.
#'
#' @export
#'
#' @author John Brzustowski \email{jbrzusto@@REMOVE_THIS_PART_fastmail.fm}
getMotusDBSrc = function(recv=NULL, proj=NULL, create = FALSE, dbDir = Motus$dbDir) {
if (missing(recv) + missing(proj) != 1)
stop("Must specify exactly one of `recv` or `proj`")
name = if(missing(proj)) recv else sprintf("project-%d", proj)
src = src_sqlite(file.path(dbDir, paste0(name, ".motus")), create)
ensureDBTables(src, recv, proj)
return(src)
}
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.