Learn R Programming

monitoR (version 1.2)

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, ...)

Value

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

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, as a character string formatted to your database storage; in the example we use YYYY/MM/DD, but be aware that you may need to include a full timestamp: YYYY/MM/DD 00:00:00.

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.

Author

Jon Katz

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 (FALSE) {
#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