#' @title OJO Query
#'
#' @description Query the Open Justice Oklahoma database
#'
#' @param ... Arguments to pass to glue::glue_sql
#' @param .con The ojodb connection to use
#' @param query The query to send to ojodb
#'
#' @export ojo_query
#' @returns data, a lazy tibble containing the results of the query
#' @examples
#' \dontrun{
#' ojo_query("SELECT * FROM \"case\" LIMIT 10")
#' ojo_query("SELECT * FROM iic.inmate LIMIT 10")
#' }
#'
ojo_query <- function(query, ..., .con = NULL) {
if (is.null(.con)) {
.con <- ojo_connect(...)
}
if (!inherits(.con, "PqConnection")) {
rlang::abort("Direct SQL querying is currently only supported for Postgres backends. Make sure your connection is using `ojo_connect(.driver = 'RPostgres')`")
}
dplyr::tbl(.con, sql(query))
}
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.