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
)path to the SQLite query log file. Defaults to the path set in read_secret("db.query_log_sqlite").
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().
if TRUE, add the joins to the table
if TRUE, return only the joins table instead of the main query log
user name that ran the query
type of source, e.g. "Diver" or "MySQL"
the DSN used to connect
the project used to connect
the cBase used to connect (if applicable)
the SQL query that was run
number of rows returned
number of columns returned
duration of the query in seconds
a logical to indicate whether info should be printed
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
} # }