We have a PostgreSQL database at work. Every time I want to connect to it, I'm manually executing the following code to build my connection and it works just fine.
library(RPostgreSQL)
con <- dbConnect(dbDriver("PostgreSQL"),
dbname = "company_xy",
host = "db.company_xy.de",
port = 5432,
user = rstudioapi::askForPassword("User"),
password = rstudioapi::askForPassword("Password!"))
I now want to start using the Connections pane but despite trying in multiple ways to set it up, I never got it working. This is the process I followed as described in the RStudio documentation:
1.Click on New Connection
2.Select PostgreSQL Unicode(x64)
3.In the parameters window I paste in the following code:
Driver = "PostgreSQL",
Server = "db.company_xy.de",
Database = "company_xy",
UID = "my_username",
PWD = "my_password",
Port = 5432
I always receive the following error message:
Failure. :2.99: unexpected symbol 1: library(DBI) con <- dbConnect(odbc::odbc(), .connection_string = "Driver={PostgreSQL Unicode(x64)};Driver = "PostgreSQL
I tried removing the parenthesis and using different kind of separators between the parameters ({}, ;) but to no end. The drivers for odbc and DBI are installed.
Can anyone spot a coding mistake or did I do it wrong?