dbpf_devices_locations_add: Adds new devices_locations to database

View source: R/dbpf_devices_locations_add.R

dbpf_devices_locations_addR Documentation

Adds new devices_locations to database

Description

Inserts a data frame of new devices_locations into database.

Usage

dbpf_devices_locations_add(con, dev_loc, mode = "test")

Arguments

con

DB connection as returned by dbpf_con(). For insert priviledges specific user name and password need to be supplied.

dev_loc

Data frame with these columns (type): serialnumber (character) comment (character) sitename (character) time (POSIXct, UTC)

mode

Can be 'test' (default) or 'insert' (requires login with insert previledges)

Details

Devices_locations indicate the time when a device was put into a specific location. Until assigned to a new location, the device is then interpreted to be at that location. Insertion is done one row at a time and feedback is provided. The default mode (mode='test') only tests the data to be inserted. Insert mode (mode='insert') requires a database onnection generated with a login that has insert priviledge. In Test Mode, duplicate rows in the input data are identified. Locations and devices listed are tested for existance in the DB. The input data frame is retuned with three new columns containing test results.

Value

Original data frame with a new column 'inserted' indicating which rows were inserted. Column 'dup' indicates row for which duplicates were found and deleted, column 'dev' indicates whether a device with that serial number exits in the DB, column 'loc' indicates whether a location with that name exits in the DB. Also a column 'db_dup' if an exact duplicate row exists in the database. All five new columns are Boolean (True/False or 1/0).

Author(s)

Stephan Gruber <stephan.gruber@carleton.ca>

Examples

## Not run: 
con    <- dbpf_con()
devices_locations <- data.frame(serialnumber="E50DBD",
                                comment="example",
                                sitename="field_site_1",
                                time = lubridate::now())
result <- dbpf_devices_locations_add(con, devices_locations, mode="test")
dbDisconnect(con)

## End(Not run)

geocryology/PermafrostDB documentation built on April 17, 2025, 11:54 a.m.