dabr: Database Management with R logo

R build status

The goal of dabr is to provide functions to manage databases: select, update, insert, and delete records, list tables, backup tables as CSV files, and import CSV files as tables.

Installation

You can install the released version of dabr from CRAN with:

install.packages("dabr")

And the development version from GitHub with:

# install.packages("remotes")
remotes::install_github("special-uor/dabr", "dev")

Example

Connecting to the Reading Palaeofire Database (RPD), locally installed under the name RPD-latest:

conn <- dabr::open_conn_mysql("RPD-latest", 
                              password = rstudioapi::askForPassword(prompt = "Password"))

Explore the database structure by listing the tables and their attributes:

dabr::list_tables(conn)
#> 
#> 
#> |age_model |
#> |:---------|
#> |ID_MODEL  |
#> |ID_SAMPLE |
#> |mean      |
#> |median    |
#> |UNCERT_5  |
#> |UNCERT_25 |
#> |UNCERT_75 |
#> |UNCERT_95 |
#> 
#> 
#> |chronology       |
#> |:----------------|
#> |ID_MODEL         |
#> |ID_SAMPLE        |
#> |original_est_age |
#> 
#> 
#> |date_info           |
#> |:-------------------|
#> |ID_ENTITY           |
#> |ID_DATE_INFO        |
#> |material_dated      |
#> |date_type           |
#> |avg_depth           |
#> |thickness           |
#> |lab_number          |
#> |age_C14             |
#> |age_calib           |
#> |error               |
#> |correlation_info    |
#> |age_used            |
#> |reason_age_not_used |
#> |notes               |
#> 
#> 
#> |entity               |
#> |:--------------------|
#> |ID_SITE              |
#> |ID_ENTITY            |
#> |entity_name          |
#> |latitude             |
#> |longitude            |
#> |elevation            |
#> |depositional_context |
#> |measurement_method   |
#> |TYPE                 |
#> |source               |
#> |core_location        |
#> |last_updated         |
#> |ID_UNIT              |
#> 
#> 
#> |entity_link_publication |
#> |:-----------------------|
#> |ID_ENTITY               |
#> |ID_PUB                  |
#> 
#> 
#> |model_name |
#> |:----------|
#> |ID_MODEL   |
#> |model_name |
#> 
#> 
#> |publication |
#> |:-----------|
#> |ID_PUB      |
#> |citation    |
#> |pub_DOI_URL |
#> |bibentry    |
#> 
#> 
#> |sample                      |
#> |:---------------------------|
#> |ID_ENTITY                   |
#> |ID_SAMPLE                   |
#> |avg_depth                   |
#> |sample_thickness            |
#> |charcoal_measurement        |
#> |analytical_sample_size      |
#> |analytical_sample_size_unit |
#> 
#> 
#> |site             |
#> |:----------------|
#> |ID_SITE          |
#> |site_name        |
#> |latitude         |
#> |longitude        |
#> |elevation        |
#> |site_type        |
#> |water_depth      |
#> |basin_size_class |
#> |catch_size_class |
#> |flow_type        |
#> |basin_size_km2   |
#> |catch_size_km2   |
#> 
#> 
#> |unit    |
#> |:-------|
#> |ID_UNIT |
#> |UNIT    |

ALWAYS! close your connection to the database (when you are done):

dabr::close_conn(conn)