2020-11-25 22:34:05 +01:00
|
|
|
source("renv/activate.R")
|
2020-12-04 20:57:13 +01:00
|
|
|
library(RMariaDB)
|
2020-11-25 22:34:05 +01:00
|
|
|
library("dplyr", warn.conflicts = F)
|
|
|
|
library(readr)
|
|
|
|
library(stringr)
|
|
|
|
library(yaml)
|
|
|
|
|
|
|
|
|
|
|
|
participant_file <- snakemake@input[["participant_file"]]
|
|
|
|
source <- snakemake@params[["source"]]
|
|
|
|
table <- snakemake@params[["table"]]
|
|
|
|
sensor_file <- snakemake@output[[1]]
|
|
|
|
|
|
|
|
participant <- read_yaml(participant_file)
|
|
|
|
record_id <- participant$PHONE$LABEL
|
|
|
|
|
2020-12-04 20:57:13 +01:00
|
|
|
dbEngine <- dbConnect(MariaDB(), default.file = "./.env", group = source$DATABASE_GROUP)
|
2020-11-25 22:34:05 +01:00
|
|
|
query <- paste0("SELECT * FROM ", table, " WHERE record_id = '", record_id, "'")
|
|
|
|
sensor_data <- dbGetQuery(dbEngine, query)
|
|
|
|
dbDisconnect(dbEngine)
|
|
|
|
|
|
|
|
write_csv(sensor_data, sensor_file)
|