Small helper function to retrieve a query from the database. if no follow-up number is provided, all messages will be collected.
Usage
db_get_query(
  db_path,
  query_id,
  n = NULL,
  db_table = "query_data",
  slice_vars = "timestamp",
  group_vars = c("query_id", "n")
)Arguments
- db_path
 Character vector. Needs to be a valid path to a database.
- query_id
 Character string with the query identifier to extract from the database.
- n
 (optional) numerical or character string, with the query follow-up number to extract
- db_table
 Character vector with the name of the table to read from.
- slice_vars
 Character vector. Names of the variables that will be used to slice the data frame. Note that the order matters: Slicing will occur for each variable in this vector successively,
- group_vars
 Character vector. Variable names of the variables to perform the grouping on.
Examples
local({
temp_path <- withr::local_tempfile(fileext = ".sqlite")
con <- get_db_connection(temp_path)
new_query <- dplyr::tibble(
 query_id = "ID124234",
 subject_id = "ID1",
 n = 1,
 timestamp = "2024-02-05 01:01:01",
 other_info = "testinfo"
)
DBI::dbWriteTable(con, "query_data", new_query)
db_get_query(temp_path, query_id = "ID124234", n = 1)
})
#> # A tibble: 1 × 5
#>   query_id subject_id     n timestamp           other_info
#>   <chr>    <chr>      <dbl> <chr>               <chr>     
#> 1 ID124234 ID1            1 2024-02-05 01:01:01 testinfo  
