% Generated by roxygen2: do not edit by hand
% Please edit documentation in R/shiny.R
\name{ggsql_session_reader}
\alias{ggsql_session_reader}
\title{Set the ggsql reader for the current Shiny session}
\usage{
ggsql_session_reader(reader, session = shiny::getDefaultReactiveDomain())
}
\arguments{
\item{reader}{A \code{Reader} object created by \code{\link[=duckdb_reader]{duckdb_reader()}}.}

\item{session}{The Shiny session object. Defaults to the current session.}
}
\value{
The \code{reader}, invisibly.
}
\description{
Registers a \code{\link[=duckdb_reader]{duckdb_reader()}} for use by all \code{\link[=renderGgsql]{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.
}
\examples{
\dontshow{if (interactive() && requireNamespace("shiny", quietly = TRUE)) withAutoprint(\{ # examplesIf}
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)
\dontshow{\}) # examplesIf}
}
