View source: R/dbpf_devices_locations_add.R
dbpf_devices_locations_add | R Documentation |
Inserts a data frame of new devices_locations into database.
dbpf_devices_locations_add(con, dev_loc, mode = "test")
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) |
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.
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).
Stephan Gruber <stephan.gruber@carleton.ca>
## 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)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.