This function requires an installed ODBC driver for MS SQL Server 2012. The database credentials are handled via environment variables.

w2_online(
  db_drv = Sys.getenv("W2_DRV"),
  db_srv = Sys.getenv("W2_SRV"),
  db_name = Sys.getenv("W2_DB"),
  db_user = Sys.getenv("W2_UN"),
  db_pass = Sys.getenv("W2_PW"),
  db_port = Sys.getenv("W2_PT"),
  verbose = wastdr::get_wastdr_verbose(),
  dsn = Sys.getenv("W2_DSN"),
  use_rodbc = Sys.getenv("W2_RODBC", FALSE)
)

Arguments

db_drv

Database driver, default: Sys.getenv("W2_DRV") which should resolve to e.g. "/usr/lib/x86_64-linux-gnu/odbc/libtdsodbc.so".

db_srv

Database server, default: Sys.getenv("W2_SRV"), which should resolve to a valid server hostname, e.g. "myserver.corporateict.domain".

db_name

The database name, default: Sys.getenv("W2_DB"), which should resolve to a valid database name, e.g. turtle_tagging.

db_user

The read-permitted database user, default: Sys.getenv("W2_UN").

db_pass

The database user's password, default: Sys.getenv("W2_PW").

db_port

The database port, default: Sys.getenv("W2_PT"), which should resolve to a numeric port, e.g. 1234.

verbose

Whether to show debug messages. Default: wastdr::get_wastdr_verbose()

dsn

The DSN for Windows systems, default: Sys.getenv("W2_DSN").

use_rodbc

Whether to use the RODBC library (if TRUE, best for Windows systems), or the odbc/DBI library (if FALSE, default, best for GNU/Linux systems).

Value

(lgl) TRUE if WAMTRAM2 is accessible and online, else FALSE.

Details

In Windows systems, create a user defined DSN with settings

  • name WAMTRAMPROD

  • server kens-mssql-001-prod.corporateict.domain

  • SQL auth using login ID and password entered by user

  • trust server certificate (this is where odbc falls over)

Add to .Renviron: W2_RODBC=TRUE W2_DSN="WAMTRAMPROD"

See also

Other wamtram: download_w2_data(), map_wamtram()

Examples

if (FALSE) {
# Credentials are set in .Renviron

w2_online()
#> TRUE
#> FALSE
}