Browse Source

Iniciando el paquete.

main
Costa 2 years ago
parent
commit
0dd2260a17
11 changed files with 88 additions and 0 deletions
  1. +1
    -0
      DESCRIPTION
  2. +1
    -0
      NAMESPACE
  3. +13
    -0
      R/sqlBackUp.R
  4. +9
    -0
      R/sqlConnect.R
  5. +8
    -0
      R/sqlFile.R
  6. +5
    -0
      R/sqlInitialize.R
  7. +3
    -0
      config/BDpath.R
  8. +12
    -0
      man/sqlBackUp.Rd
  9. +12
    -0
      man/sqlConnect.Rd
  10. +12
    -0
      man/sqlFile.Rd
  11. +12
    -0
      man/sqlInitialize.Rd

+ 1
- 0
DESCRIPTION

@ -8,3 +8,4 @@ Description: BD functions for CIT lab.
License: What license is it under? License: What license is it under?
Encoding: UTF-8 Encoding: UTF-8
LazyData: true LazyData: true

+ 1
- 0
NAMESPACE

@ -0,0 +1 @@
exportPattern("^[[:alpha:]]+")

+ 13
- 0
R/sqlBackUp.R

@ -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)
}

+ 9
- 0
R/sqlConnect.R

@ -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)
}
}

+ 8
- 0
R/sqlFile.R

@ -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]])
}
}

+ 5
- 0
R/sqlInitialize.R

@ -0,0 +1,5 @@
sqlInitialize<-function(){
library(tidyverse)
library(RODBC)
library(openxlsx)
}

+ 3
- 0
config/BDpath.R

@ -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"

+ 12
- 0
man/sqlBackUp.Rd

@ -0,0 +1,12 @@
\name{sqlBackUp}
\alias{sqlBackUp}
\title{sqlBackUp}
\usage{
sqlBackUp(dbfile=file,conn=dta,bu.dir=NULL)
}
\description{
sqlBackUp.
}
\examples{
sqlBackUp()
}

+ 12
- 0
man/sqlConnect.Rd

@ -0,0 +1,12 @@
\name{sqlConnect}
\alias{sqlConnect}
\title{sqlConnect}
\usage{
sqlConnect(file, pass=T)
}
\description{
sqlConnect.
}
\examples{
sqlConnect(sqlFile())
}

+ 12
- 0
man/sqlFile.Rd

@ -0,0 +1,12 @@
\name{sqlFile}
\alias{sqlFile}
\title{sqlFile}
\usage{
sqlFile(file=1, list=F)
}
\description{
sqlFile.
}
\examples{
sqlFile()
}

+ 12
- 0
man/sqlInitialize.Rd

@ -0,0 +1,12 @@
\name{sqlInitialize}
\alias{sqlInitialize}
\title{sqlInitialize}
\usage{
sqlInitialize()
}
\description{
sqlInitialize.
}
\examples{
sqlInitialize()
}

Loading…
Cancel
Save