db_ts_store: Store a Time Series to the Database

View source: R/store_time_series.R

db_ts_storeR Documentation

Store a Time Series to the Database

Description

Stores one or more time series to the database.

Usage

db_ts_store(
  con,
  x,
  access = NULL,
  valid_from = NULL,
  release_date = NULL,
  pre_release_access = NULL,
  schema = "timeseries"
)

Arguments

con

RPostgres connection object.

x

Object containing time series to store. Single ts or xts objects are allowed as well as objects of type list, tslist, and data.table.

access

character Access level for all ts to be stored. If set to NA (default) the database set it to 'main' access.

valid_from

character representation of a date in the form of 'YYYY-MM-DD'. valid_from starts a new version

release_date

character date from which on this version of the time series should be made available when release date is respected. Applies to all time series in x.

pre_release_access

character Only allow access to the series being stored ahead of the release date to users with this access level. NULL (default) allows everybody. See respect_release_date in db_ts_read.

schema

character name of the database schema. Defaults to 'timeseries'

See Also

Other time series functions: db_collection_read_ts(), db_dataset_read_ts(), db_ts_delete_latest_version(), db_ts_delete(), db_ts_get_last_update(), db_ts_read_history(), db_ts_read(), db_ts_trim_history()

Examples


## Not run: 
# storing zrh_airport data that is a list with two xts objects.
db_ts_store(con = connection, zrh_airport, schema = "schema")

# to store different versions of the data, use parameter valid_from
# different versions are stored with the same key
ch.kof.barometer <- kof_ts["baro_2019m11"]
names(ch.kof.barometer) <- c("ch.kof.barometer")
db_ts_store(
  con = connection,
  ch.kof.barometer,
  valid_from = "2019-12-01",
  schema = "schema"
)

ch.kof.barometer <- kof_ts["baro_2019m12"]
names(ch.kof.barometer) <- c("ch.kof.barometer")
db_ts_store(
  con = connection,
  ch.kof.barometer,
  valid_from = "2020-01-01",
  schema = "schema"
)

## End(Not run)

timeseriesdb documentation built on March 24, 2022, 1:06 a.m.