Hi, I'm having trouble connecting to my postgreSQL db on Heroku(Amazon) using RPostgreSQL. I've looked through GitHub for people doing the same thing. There are quite a few examples and all look similar to the below: drv <- dbDriver("PostgreSQL") con <- dbConnect( drv, dbname = "dadqn30er7ghpl", host = "ec2-27-837-167-90.eu-west-1.compute.amazonaws.com", port = 5432, user = "tascofyvasswmblc", password = XXXXXX' ); I'm getting the error: Error in postgresqlNewConnection(drv, ...) : RS-DBI driver: (could not connect tascofyvasswmblc at ec2-27-837-167-90.eu-west-1.compute.amazonaws.com on dbname "dascn90er7ghpl" ) Any pointers would be hugely appreciated! Thanks, Izaak
I don't use PostGreSQL, but I strongly suspect that you would have this problem using other drivers as well, so pick any method described in the PostGreSQL documentation to verify that you can reach the server and your dbname from the machine where you are running R. Note that where you are connecting from may be just as important as where the server is, and configuration of any of the database, the virtual OS or the AWS environment may prevent connections for security reasons. If you have confirmed all this is working outside of R, then you should probably ask on R-sig-db for R-specific help. -- Sent from my phone. Please excuse my brevity. On April 21, 2016 8:49:49 AM PDT, Izaak Rogan <izaakrogan at gmail.com> wrote:>Hi, > >I'm having trouble connecting to my postgreSQL db on Heroku(Amazon) >using RPostgreSQL. > >I've looked through GitHub for people doing the same thing. There are >quite a few examples and all look similar to the below: > >drv <- dbDriver("PostgreSQL") > >con <- dbConnect( > drv, > dbname = "dadqn30er7ghpl", > host = "ec2-27-837-167-90.eu-west-1.compute.amazonaws.com", > port = 5432, > user = "tascofyvasswmblc", > password = XXXXXX' >); > >I'm getting the error: > >Error in postgresqlNewConnection(drv, ...) : > RS-DBI driver: (could not connect >tascofyvasswmblc at ec2-27-837-167-90.eu-west-1.compute.amazonaws.com on >dbname "dascn90er7ghpl" >) > >Any pointers would be hugely appreciated! > >Thanks, >Izaak > >______________________________________________ >R-help at r-project.org mailing list -- To UNSUBSCRIBE and more, see >https://stat.ethz.ch/mailman/listinfo/r-help >PLEASE do read the posting guide >http://www.R-project.org/posting-guide.html >and provide commented, minimal, self-contained, reproducible code.[[alternative HTML version deleted]]
On heroku the database uri is stored in an environment variable.> db_uri = Sys.getenv(''DATABASE_URL')I'm not sure if you can use that directly or if you will need to parse it for username, password etc. On Thu, 2016-04-21 at 16:49 +0100, Izaak Rogan wrote:> Hi, > > I'm having trouble connecting to my postgreSQL db on Heroku(Amazon) > using RPostgreSQL. > > I've looked through GitHub for people doing the same thing. There are > quite a few examples and all look similar to the below: > > drv <- dbDriver("PostgreSQL") > > con <- dbConnect( > drv, > dbname = "dadqn30er7ghpl", > host = "ec2-27-837-167-90.eu-west-1.compute.amazonaws.com", > port = 5432, > user = "tascofyvasswmblc", > password = XXXXXX' > ); > > I'm getting the error: > > Error in postgresqlNewConnection(drv, ...) : > RS-DBI driver: (could not connect > tascofyvasswmblc at ec2-27-837-167-90.eu-west-1.compute.amazonaws.com on > dbname "dascn90er7ghpl" > ) > > Any pointers would be hugely appreciated! > > Thanks, > Izaak > > ______________________________________________ > R-help at r-project.org mailing list -- To UNSUBSCRIBE and more, see > https://stat.ethz.ch/mailman/listinfo/r-help > PLEASE do read the posting guide http://www.R-project.org/posting-guide.html > and provide commented, minimal, self-contained, reproducible code.