This produces a connection object to a FRAM database, which is a necessary precursor for almost all framrsquared functions. For most users, can just treat the connection object as a black box that's used as an argument in other functions. See details for an explanation of the returned object.
Arguments
- db_path
Path to a FRAM database.
- read_only
Logical, defaults to FALSE. Optional argument to flag this connection as read-only (if set to
TRUE). IfTRUE, framrsquared functions that modify the database will abort rather than run. Use as a safety feature when working with a database that must not be modified.- quiet
Logical, defaults to FALSE. Optional argument; when TRUE, silences success message and database summary.
Details
The returned object of connect_fram_db() is a list of useful objects for other framrsquared functions.
$fram_db_connectionconnection object, used for SQL calls.
$fram_db_connection_idconnection name in .fram_connections, used for orphan cleanup via
disconnect_all_fram_connections().$fram_db_type"full" or "transfer", useful for validation for specific functions.
$fram_db_species"COHO" or "CHINOOK"
$fram_db_speciesfiletype, typeically "mdb"
$fram_read_onlyOptional user-specified safety measure, TRUE or FALSE. Functions that modify the fram database should error out if TRUE.
framrsquared creates a special environment in the global environment, .fram_connections. Whenever a new connection is made with connect_fram_db, it is added to that environment as well; whenever the connection is closed with disconnect_fram_db(), the connection is removed from that environment. This tracking allows disconnect_all_fram_connections() to clear out any orphan connections made by assigning a connection to an existing connection object.
Examples
if (FALSE) fram_db <- connect_fram_db('<path>')
fram_db |> fetch_table("Mortality") # \dontrun{}
#> Error: object 'fram_db' not found