| dbPool {pool} | R Documentation |
A wrapper around poolCreate to simplify the creation of a DBI
database connection pool. Check the documentation of poolCreate
for a generic overview of the parent function and the Pool object. The
main thing to point out is that, for dbPool, you always need to
provide a DBI driver (i.e. of class DBIDriver-class),
and it should always be accompanied by the required authorization
arguments (see the example below).
dbPool(drv, ..., validateQuery = NULL)
drv |
An object that inherits from |
... |
Arguments needed for both
|
validateQuery |
The query to run to verify that the connection
is valid (it should be as simple as possible). If this is not
provided, |
if (requireNamespace("RMySQL", quietly = TRUE)) {
pool <- dbPool(
drv = RMySQL::MySQL(),
dbname = "shinydemo",
host = "shiny-demo.csa7qlmguqrf.us-east-1.rds.amazonaws.com",
username = "guest",
password = "guest"
)
dbGetQuery(pool, "SELECT * from City LIMIT 5;")
#> ID Name CountryCode District Population
#> 1 1 Kabul AFG Kabol 1780000
#> 2 2 Qandahar AFG Qandahar 237500
#> 3 3 Herat AFG Herat 186800
#> 4 4 Mazar-e-Sharif AFG Balkh 127800
#> 5 5 Amsterdam NLD Noord-Holland 731200
poolClose(pool)
} else {
message("Please install the 'RMySQL' package to run this example")
}