Convenience functions to execute a prewritten SQL query. Wrappers for RODBC::sqlQuery
with no additional processing.
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, ...)
dbDownloadCardRecorderID
returns a data frame with fields pkCardRecorderID, fldLocationNameAbbreviation, fldSerialNumber, and pkCardID. dbDownloadSurvey
returns a data frame with a single field: fldSurveyName.
Name of the ODBC connector data source corresponding to the acoustics database.
User ID to allow ODBC connector to connect to database, if not present in ODBC connector.
Password to allow ODBC connector to connect to database, if not present in ODBC connector.
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
.
Location prefix or vector of six-character prefixes by which to filter results.
Numerical sampling rate of surveys (Hz).
Character file extension "wav" or "mp3".
Additional arguments to RODBC::odbcConnect
.
Jon Katz
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.
sqlQuery
, dbDownloadTemplate
, dbUploadSurvey
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