with_postgres_connection: Runs a temporary postgres instande in a docker container

View source: R/postgres.R

with_postgres_connectionR Documentation

Runs a temporary postgres instande in a docker container

Description

Runs a temporary postgres instande in a docker container

Usage

with_postgres_connection(
  image_name,
  code,
  user = NULL,
  password = NULL,
  database = NULL,
  port = 5432
)

Arguments

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

Details

In the passed code you can refer to the con variable that stores the postgres connection. See examples

Examples


if (stevedore::docker_available()) {
  with_postgres_connection("postgres:12.10", {
    DBI::dbGetQuery(con, "select version();")
  })
}


szymanskir/magician documentation built on April 3, 2022, 12:06 a.m.