
Create a connection pool for Shiny apps (main database)
create_pool_main.RdCreates a connection pool using the pool package. This is the recommended approach for Shiny applications as it automatically manages connections, preventing connection leaks and exhaustion.
Usage
create_pool_main(
pass = NULL,
user = NULL,
minSize = 1,
maxSize = 5,
use_env_credentials = FALSE
)Examples
if (FALSE) { # \dontrun{
# In your Shiny app server function:
pool_main <- create_pool_main()
onStop(function() {
pool::poolClose(pool_main)
})
# Use the pool in queries:
data <- pool::poolWithTransaction(pool_main, function(conn) {
DBI::dbGetQuery(conn, "SELECT * FROM table_name")
})
} # }