The read_query_log() function reads the query log from a SQLite database. The write_query_log() function writes a query log entry. Join queries from presets are stored in a separate table and linked to their parent query; use read_query_log() to retrieve them together.

read_query_log(
  log_file = read_secret("db.query_log_sqlite"),
  date_range = this_year(),
  with_joins = TRUE,
  joins_only = FALSE
)

write_query_log(
  log_file,
  user,
  source_type,
  source_dsn,
  source_project,
  source_cbase = NA_character_,
  query,
  rows,
  columns,
  duration_secs = NA_real_,
  print = TRUE
)

Arguments

log_file

path to the SQLite query log file. Defaults to the path set in read_secret("db.query_log_sqlite").

date_range

date range to filter log entries on, can be length 1 or 2 (or more to use the min/max). Defaults to certetoolbox::this_year(). Use NULL to return all entries. Can also be years, or functions such as last_month().

with_joins

if TRUE, add the joins to the table

joins_only

if TRUE, return only the joins table instead of the main query log

user

user name that ran the query

source_type

type of source, e.g. "Diver" or "MySQL"

source_dsn

the DSN used to connect

source_project

the project used to connect

source_cbase

the cBase used to connect (if applicable)

query

the SQL query that was run

rows

number of rows returned

columns

number of columns returned

duration_secs

duration of the query in seconds

print

a logical to indicate whether info should be printed

Examples

if (FALSE) { # \dontrun{

read_query_log() # this year (default)
read_query_log(date_range = 2024) # all of 2024
read_query_log(date_range = last_month()) # last month
read_query_log(date_range = c(2023, 2025)) # range of years
read_query_log(date_range = NULL) # everything
} # }