code/exampledb.R

library("RPostgreSQL")

usr <- "dbuser"
pwd <- "dbpassword"

# loads the PostgreSQL driver
drv <- dbDriver("PostgreSQL")

# creates a connection to the postgres database
# note that "con" will be used later in each connection to the database
con <- dbConnect(
  drv, 
  dbname = usr,
  host = "db", 
  port = 5432,
  user = usr, 
  password = pwd
)


dbExistsTable(con, "tab2")


dbWriteTable(
    conn = con, 
    name = "tab2", 
    value = iris,
    append = TRUE, 
    row.names = FALSE
)
gowerc/projectTemplate documentation built on June 1, 2019, 6:06 p.m.