about-podr

library(podr)

Function conn_podr

Database Info:

    Host: podr.phuse.global
    Database: nihpo
    Port number: 5432
    Username: <your user name>
    Password: <your password>
  library(RPostgres)
  usr <- 'phuse_su67e99huj';
  pwd <- 'bGopEaaIQ7uB';
  con  <- conn_podr(usr,pwd) 
  str(con)
#> Formal class 'PqConnection' [package "RPostgres"] with 3 slots
#>   [email protected] ptr     :<externalptr> 
#>   [email protected] bigint  : chr "integer64"
#>   [email protected] typnames:'data.frame': 1199 obs. of  2 variables:
#>   .. ..$ oid    : int [1:1199] 16 17 18 19 20 21 22 23 24 25 ...
#>   .. ..$ typname: chr [1:1199] "bool" "bytea" "char" "name" ...

Function read_podr

  library(tibble)
  library(stringr)
  library("DT")
  # Case 1: use query string to call read_podr 
  qry <- "SELECT table_name FROM information_schema.tables WHERE table_schema = 'public'";
  # cc <- read_podr(con = con, query_string = qry, limit = 1000 ) %>%
  #      add_column(libname = gsub('_[[:alpha:]]+$', '\\1', .[,"table_name"], ignore.case = TRUE )) %>%
  #      add_column(dataset = str_extract(.[,"table_name"], '([[:alpha:]]+)$' ))
  c1 <- read_podr(con = con, query_string = qry, limit = 1000 )
#>  chr "podr::read_podr: SELECT table_name FROM information_schema.tables WHERE table_schema = 'public' limit 1000"
  c2 <- add_column(c1, libname = gsub('_[[:alpha:]]+$', '\\1', c1[,"table_name"], ignore.case = TRUE ))
  cc <- add_column(c2, dataset = str_extract(c2[,"table_name"], '([[:alpha:]]+)$' ))
  DT::datatable(cc)
  # Case 2: read record for a table
  tb <- 'virtual_css_2020_sdtm_ae'
  c2 <- read_podr(tabname = tb)
#>  chr "podr::read_podr: select * from public.virtual_css_2020_sdtm_ae limit 100"
  DT::datatable(c2)
  # Case 3: read record for a data set in a library/category
  lb <- 'virtual_css_2020_sdtm';
  ds <- 'cm'
  c3 <- read_podr(libname = lb, dataset = ds)
#>  chr "podr::read_podr: select * from public.virtual_css_2020_sdtm_cm limit 100"
  DT::datatable(c3)

Function get_table_names

Calls to read_podr and gets a list of tables from PODR.

  cc <- get_table_names()
#>  chr "podr::read_podr: SELECT table_name FROM information_schema.tables WHERE table_schema = 'public' limit 1000"
  datatable(cc)

Function get_table_defs

Calls to read_podr and gets table definition for a table in PODR.

tb <- 'virtual_css_2020_sdtm_ae'
rr <- get_table_defs(tb) 
#>  chr "podr::read_podr: SELECT * FROM information_schema.columns WHERE table_name = 'virtual_css_2020_sdtm_ae' limit 1000"
DT::datatable(rr)