importData: import data from Food Co-op's Backup

Description Usage Arguments Details Value Examples

Description

importData() connects to a Food Co-op's SQLite database. A query gives back the current turnover of the Food Co-op and writes the result in a second database.

Usage

1
importData(FROM, TO)

Arguments

FROM

the path to the backup database.

TO

a list containing 'nameTable' and 'path' of the second database = the database where the query shall be dropped

Details

The names of the character strings inside the list of parameter TO need to be the same as they are writte above (or look at examples).

Value

No value is returned but a table is written in the second database.

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
#### load dataset ####
path <- system.file("data", package = "foodstorage")
files <- list.files(path)
# filter all backups (files which end up with .BAK)
backups <- files[which(stringr::str_detect(files, ".BAK$"))]
current_backup <- backups[length(backups)] # use newest backup
pathToBackup <- file.path(path, current_backup)

# test result of file.path -> if file doesn't exist, length(result) will be 0
kornInfoExists <- files[which(stringr::str_detect(files, "kornInfo.sqlite"))]
pathToKornInfo <- file.path(path, kornInfoExists)
# create list for parameter 'TO'
TO <- list(nameDB = "kornInfo.sqlite", nameTable = "kornumsatz_origin", path = pathToKornInfo)

importData(FROM = pathToBackup, TO = TO)

frumentum/foodcoop-storage documentation built on May 16, 2019, 3:33 p.m.