Learn R Programming

monitoR (version 1.0.3)

dbDownload: Retrieve Card-Recorder ID Values or Survey Names from a Database

Description

Convenience functions to execute a prewritten SQL query. Wrappers for RODBC::sqlQuery with no additional processing.

Usage

dbDownloadCardRecorderID(db.name = "acoustics", uid, pwd, 
date.deployed, date.collected, loc.prefix, ...)

dbDownloadSurvey(db.name = "acoustics", uid, pwd, start.date, end.date, loc.prefix, samp.rate, ext, ...)

Arguments

db.name
Name of the ODBC connector data source corresponding to the acoustics database.
uid
User ID to allow ODBC connector to connect to database, if not present in ODBC connector.
pwd
Password to allow ODBC connector to connect to database, if not present in ODBC connector.
date.deployed, date.collected, start.date, end.date
Dates to filter results, in a recognizable POSIX format: YYYY/MM/DD.
loc.prefix
Location prefix or vector of six-character prefixes by which to filter results.
samp.rate
Numerical sampling rate of surveys (Hz).
ext
Character file extension "wav" or "mp3".
...
Additional arguments to RODBC::odbcConnect.

Value

  • dbDownloadCardRecorderID returns a data frame with fields pkCardRecorderID, fldLocationNameAbbreviation, fldSerialNumber, and pkCardID. dbDownloadSurvey returns a data frame with a single field: fldSurveyName.

Details

These functions assume a database structure identical to that provided in the acoustics schema. dbDownloadCardRecorderID may be used to look up CardRecorderID values before uploading survey metadata; dbDownloadSurvey may be used to generate a table of survey names to work through for batch detection with either corMatch or binMatch. If the username and password are present in the ODBC datasource they do not need to be provided. It is possible to store only the username in the datasource and enter a password, but the reverse will not work.

See Also

sqlQuery, dbDownloadTemplate, dbUploadSurvey

Examples

Run this code
#If using the 'acoustics' schema verbatim:
CRs<-dbDownloadCardRecorderID(
        date.deployed = "2012/05/22", 
        date.collected = "2012/05/29", 
        loc.prefix = "MABI01")
        
surveys<-dbDownloadSurvey(
        start.date = "2012/05/22", 
        end.date = "2012/05/29", 
        loc.prefix = "MABI01", 
        samp.rate=24000,
        ext="wav")
        
#'acoustics' schema, different database name:
CRs<-dbDownloadCardRecorderID(
        db.name = "LocalSQLdb", 
        uid = "EntryOnly", 
        pwd = "07H23BBM", 
        date.deployed = "2012/05/22", 
        date.collected = "2012/05/29", 
        loc.prefix = "MABI01")
        
surveys<-dbDownloadSurvey(
        db.name = "LocalSQLdb", 
        uid = "EntryOnly", 
        pwd = "07H23BBM", 
        start.date = "2012/05/22", 
        end.date = "2012/05/29", 
        loc.prefix = "MABI01", 
        samp.rate=24000,
        ext="wav")

Run the code above in your browser using DataLab