with_postgres_connection | R Documentation |
Runs a temporary postgres instande in a docker container
with_postgres_connection( image_name, code, user = NULL, password = NULL, database = NULL, port = 5432 )
image_name |
name of the docker image with postgres to use |
code |
the code to execute that uses the postgres connection |
user |
user used for creating the postgres connection |
password |
password used for creating the postgres connection |
database |
database used for creating the postgres connection |
port |
port of the docker container to expose |
In the passed code you can refer to the con
variable
that stores the postgres connection. See examples
if (stevedore::docker_available()) { with_postgres_connection("postgres:12.10", { DBI::dbGetQuery(con, "select version();") }) }
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.