Registers a duckdb_reader() for use by all renderGgsql() outputs in the
current Shiny session. Must be called from within a Shiny server function
(i.e., while a session is active). The reader is automatically cleaned up
when the session ends.
Usage
ggsql_session_reader(reader, session = shiny::getDefaultReactiveDomain())Arguments
- reader
A
Readerobject created byduckdb_reader().- session
The Shiny session object. Defaults to the current session.
Examples
if (FALSE) { # interactive() && requireNamespace("shiny", quietly = TRUE)
library(shiny)
ui <- fluidPage(
ggsqlOutput("chart")
)
server <- function(input, output, session) {
ggsql_session_reader(duckdb_reader())
output$chart <- renderGgsql({
"SELECT * FROM r:mtcars VISUALISE mpg AS x, disp AS y DRAW point"
})
}
shinyApp(ui, server)
}
