bedatadriven / activityinfo-R

ActivityInfo R Language Client
https://www.activityinfo.org/support/docs/R/
17 stars 12 forks source link

Get database resources as a table #61

Closed akbertram closed 1 year ago

akbertram commented 1 year ago

Split from https://github.com/bedatadriven/activityinfo-R/issues/32#issuecomment-1354759271

getFormSchema() has a method that allows you to transform it into a data.frame but getDatabaseSchema() currently does not.

it'll be nice to get the database schema into a data.frame format as well so that updates to the database schema can also be handled via data.frames , similar to #33



afda_schema <- getDatabaseSchema("c5h9mudkz3sqce52")

## Tables come from the "resources" list
## turn below code into a function

## Get table labels
tab_label <- afda_schema %>% 
  purrr::pluck("resources") %>% 
  purrr::map(pluck("label")) %>% unlist()

## Get table IDs
tab_id <- afda_schema %>% 
  purrr::pluck("resources") %>% 
  purrr::map(pluck("id")) %>% 
  unlist()

## put 'em together to create a nice look-up
data.frame(
  Table = tab_label,
  table_id = tab_id
)
``
akbertram commented 1 year ago

See getResources()