Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- library(RPostgreSQL)
- # create a connection
- # save the password
- pw <- "password"
- # alteratively, store in an external file.
- ps <- readline(file('password.txt', open = 'r'))
- # 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 = "cake",
- host = "localhost", port = 5432,
- user = "username", password = pw)
- rm(pw) # removes the password
- # check for the cartable
- dbExistsTable(con, "table_name")
- # TRUE
- data <- dbReadTable(con, 'table_name')
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement