| @ -0,0 +1 @@ | |||||
| exportPattern("^[[:alpha:]]+") | |||||
| @ -0,0 +1,13 @@ | |||||
| sqlBackUp<-function(dbfile=file,conn=dta,bu.dir=NULL){ | |||||
| if(sqlTables(conn) %>% filter(TABLE_NAME == "UMID") %>% nrow > 0){bu.dir<-"BU_UM"} | |||||
| if(sqlTables(conn) %>% filter(TABLE_NAME == "OVID") %>% nrow > 0){bu.dir<-"BU_OVARIO"} | |||||
| db=strsplit(dbfile, "/")[[1]]%>% tail(n=1) | |||||
| bu_path<-gsub(db,bu.dir,dbfile) | |||||
| if (!dir.exists(bu_path)){ | |||||
| dir.create(bu_path) | |||||
| print(paste0("Back Up directory ", bu_path, " created")) | |||||
| } | |||||
| cp_bu<-paste0(bu_path, "/", format(Sys.time(), format="%Y%m%d"),"-",db) | |||||
| file.copy(dbfile, cp_bu) | |||||
| } | |||||
| @ -0,0 +1,9 @@ | |||||
| sqlConnect<-function(file, pass=T){ | |||||
| sqlInitialize() | |||||
| if (pass){ | |||||
| dta<-odbcConnectAccess2007(access.file = file, | |||||
| pwd = .rs.askForPassword("Enter password:")) | |||||
| }else{ | |||||
| dta<-odbcConnectAccess2007(access.file = file) | |||||
| } | |||||
| } | |||||
| @ -0,0 +1,8 @@ | |||||
| sqlFile<-function(file=1, list=F){ | |||||
| source(paste0(.libPaths(),"/BDCIT/config/BDpath.R"), encoding = "UTF-8") | |||||
| if (list){ | |||||
| print(sqlFiles) | |||||
| }else{ | |||||
| return(sqlFiles[[file]]) | |||||
| } | |||||
| } | |||||
| @ -0,0 +1,5 @@ | |||||
| sqlInitialize<-function(){ | |||||
| library(tidyverse) | |||||
| library(RODBC) | |||||
| library(openxlsx) | |||||
| } | |||||
| @ -0,0 +1,3 @@ | |||||
| sqlFiles<-list() | |||||
| sqlFiles[[1]]<-"C:/Users/47926492N/OneDrive - IDIBELL - Institut d'Investigació Biomèdica de Bellvitge/RATG-PIULATS/OVARIO.accdb" | |||||
| sqlFiles[[2]]<-"C:/Users/47926492N/OneDrive - IDIBELL - Institut d'Investigació Biomèdica de Bellvitge/RATG-PIULATS/MELANOMA UVEAL CIT.accdb" | |||||
| @ -0,0 +1,12 @@ | |||||
| \name{sqlBackUp} | |||||
| \alias{sqlBackUp} | |||||
| \title{sqlBackUp} | |||||
| \usage{ | |||||
| sqlBackUp(dbfile=file,conn=dta,bu.dir=NULL) | |||||
| } | |||||
| \description{ | |||||
| sqlBackUp. | |||||
| } | |||||
| \examples{ | |||||
| sqlBackUp() | |||||
| } | |||||
| @ -0,0 +1,12 @@ | |||||
| \name{sqlConnect} | |||||
| \alias{sqlConnect} | |||||
| \title{sqlConnect} | |||||
| \usage{ | |||||
| sqlConnect(file, pass=T) | |||||
| } | |||||
| \description{ | |||||
| sqlConnect. | |||||
| } | |||||
| \examples{ | |||||
| sqlConnect(sqlFile()) | |||||
| } | |||||
| @ -0,0 +1,12 @@ | |||||
| \name{sqlFile} | |||||
| \alias{sqlFile} | |||||
| \title{sqlFile} | |||||
| \usage{ | |||||
| sqlFile(file=1, list=F) | |||||
| } | |||||
| \description{ | |||||
| sqlFile. | |||||
| } | |||||
| \examples{ | |||||
| sqlFile() | |||||
| } | |||||
| @ -0,0 +1,12 @@ | |||||
| \name{sqlInitialize} | |||||
| \alias{sqlInitialize} | |||||
| \title{sqlInitialize} | |||||
| \usage{ | |||||
| sqlInitialize() | |||||
| } | |||||
| \description{ | |||||
| sqlInitialize. | |||||
| } | |||||
| \examples{ | |||||
| sqlInitialize() | |||||
| } | |||||