df_srdm: Prepare data.frame information for SRDM

View source: R/df2sqlite.R

df_srdmR Documentation

Prepare data.frame information for SRDM

Description

Personal use!. Check whether the data frame meets the requirements of SRDM, and output the basic information of the data to standard output

Usage

df_srdm(
  df,
  database,
  table,
  replace = FALSE,
  append = FALSE,
  write_repo = TRUE
)

Arguments

df

data.frame for archive

database

valid database name

table

valid table name

replace

logical value. Default is FALSE

append

logical value. Default is FALSE

write_repo

logical value. Weather write data infomation to SRMD repo. Default is TURE.

Examples

df$ID <- seq_len(nrow(df))
attr(df, "keys") = "ID"
for (i in seq_along(df))
    attr(df[[i]], "label") = paste("label:", names(df)[i])
fil <- tempfile("srdm")
df_srdm(df, "test", "mtcars", file = fil, replace = TRUE)
if (interactive()) file.show(fil)
database <- file.path(
    ifelse(Sys.getenv("DATA_ARCHIVE") != "",
        Sys.getenv("DATA_ARCHIVE"), "~/Data/DBMS"
    ), "test.sqlite"
)
con <- DBI::dbConnect(RSQLite::SQLite(), database)
DBI::dbListTables(con)
DBI::dbGetQuery(con, "SELECT * FROM mtcars WHERE ID <= 10")
DBI::dbDisconnect(con)

liubianshi/lbs documentation built on Nov. 2, 2023, 11:06 a.m.