Find the username and passwords specific given the username of the computer and stored or entered passwords for accessing databases that store confidential information about landings of Pacific Hake.

hakedata_sql_password(database = c("NORPAC", "PacFIN"), file)

Arguments

database

A vector of character values specifying which databases you want login information for.

file

A file path specifying where to find the passwords. The path can be full or relative to your current working directory. If a path is provided, the file that it leads to must be for a text file with one password per line for each database in the database argument and in that order. The default for database means that the file would have two lines, where the first line is the NORPAC password and the second line is the PacFIN password. These passwords should not be surrounded with quotes. If a file name is not provided, which is the default behaviour, then the user will be prompted for their passwords. This also happens if the file cannot be found given the path provided.

Value

A list with two entries, usernames and passwords. Each element will have the same number of entries as the input argument database and be named using the elements of database. The list is invisibly returned to ensure that the passwords are not printed to the screen. Thus, the function call should be assigned to an object.

Author

Kelli F. Johnson

Examples

if (FALSE) {
# Prompted for passwords for each database
test <- hakedata_sql_password()
# Prompted for passwords for each database because file is not found
test <- hakedata_sql_password(file = "doesnotwork.txt")
# On Kelli Johnson's machine, the following will work
test <- hakedata_sql_password(file = "password.txt")
# Doesn't work because entry for database is not in the list
# of allowed databases, i.e., the default for `database`.
test <- hakedata_sql_password(database = "onedatabase")
# Only look for one password
test <- hakedata_sql_password(database = "NORPAC")
}