get_data: Access and download tables from Pandora

get_dataR Documentation

Access and download tables from Pandora

Description

You can access individual tables either by establishing a DBI connection (get_con()) to them or by downloading them as a data.frame (get_df()). You'll probably not need the former, which is only relevant if you want to interact with the database server directly. get_df() does three additional things: It transforms the columns of the downloaded table to the correct data type (with enforce_types()), it adds a table name prefix to each column name and it caches the downloaded table locally. The default is a per-R-session cache, but you can cache more permanently by changing the cache_dir and cache_max_age parameters.

You can download multiple tables at once with get_con_list() and get_df_list(), which return a named list of objects. The latter again includes the additional transformation and caching features.

Some tables are restricted, i.e. the Pandora read user does not have access to certain columns. access_restricted_table() allows you to get the open (non-restricted) columns of these tables. TAB_Analysis is stored a little awkwardly in Pandora and we do a pre-joining operation with access_prejoined_data() to access its content. Both access_restricted_table() and access_prejoined_data() are called automatically if you try to access the relevant tables with get_con() or get_df(), so you usually do not have to call them explicitly.

Usage

get_con(tab = sidora.core::pandora_tables, con)

get_con_list(tab = sidora.core::pandora_tables, con)

get_df(
  tab = sidora.core::pandora_tables,
  con,
  cache = T,
  cache_dir = tempdir(),
  cache_max_age = 24 * 60 * 60
)

get_df_list(
  tab = sidora.core::pandora_tables,
  con,
  cache = T,
  cache_dir = tempdir(),
  cache_max_age = 24 * 60 * 60
)

access_restricted_table(tab, con)

access_prejoined_data(tab, con)

Arguments

tab

character vector. Names of tables

con

database connection object

cache

logical. Should data be cached?

cache_dir

character. Path to cache directory

cache_max_age

numeric. Maximum age of cache in seconds

Value

connection, list of connections, data.frame or list of data.frames


sidora-tools/sidora.core documentation built on April 30, 2023, 8:42 p.m.