Skip to contents

This function establishes a connection to the Seatrack database. Note that connections are only accepted from limited IP-adresses. Ideally, credentials should first be set using set_credentials_renviron(). This should only have to be done once per project. After this, credentials will be loaded automatically.

Usage

connectSeatrack(
  user_name = NA,
  password = NA,
  host = "seatrack.nina.no",
  dbname = "seatrack",
  ...
)

Arguments

host

Character. The host of the database. For testing purposes. There should be no need for the user to change this.

dbname

Character. Name of database, for testing purposes. Default is "seatrack" which is the production database.

Username

Character. If not provided, first attempts to check environmenta variables then calls set_credentials_renviron()

Password

Character. If not provided, first attempts to check environmenta variables then calls set_credentials_renviron()

Value

No return, a connection to the database is opened

Details

The function opens a connection to the database, which other functions in seatrackRdb will use. If a user wants to access the connection in their own R environment so as to write their own queries, they can do so using getSeatrackConnection()

Examples

if (FALSE) { # \dontrun{
connectSeatrack()
con <- getSeatrackConnection()
DBI::dbGetQuery(con, "SELECT * FROM loggers.logging_session LIMIT 10")
DBI::dbDisconnect(con)
} # }