## ----include = FALSE----------------------------------------------------------
knitr::opts_chunk$set(
  collapse = TRUE,
  comment = "#>"
)

## -----------------------------------------------------------------------------
library(qryflow)

## -----------------------------------------------------------------------------
query_send_handler <- function(con, chunk, ...) {
  res <- DBI::dbSendQuery(con, chunk$sql, ...)

  results <- DBI::dbFetch(res)

  DBI::dbClearResult(res)

  results
}

## -----------------------------------------------------------------------------
validate_qryflow_handler(query_send_handler)

## -----------------------------------------------------------------------------
register_qryflow_type(
  "query-send",
  handler = query_send_handler,
  overwrite = TRUE
)

## -----------------------------------------------------------------------------
ls_qryflow_types()

## -----------------------------------------------------------------------------
# Creates an in-memory sqlite database and populates it with an mtcars table, named "mtcars"
con <- example_db_connect(mtcars)

# Create
sql <- "
-- @query-send: df_mtcars
SELECT *
FROM mtcars;
"

results <- qryflow(con, sql)

head(results)

