Can't connect R with PostgreSQL

119 views Asked by At

I am encountering the following error while connecting RStudio with PostgreSQL.

 # Establish a connection to the PostgreSQL database
> con <- dbConnect(dbDriver("PostgreSQL"), dbname = dbname, host = host, user = user, password = password)
Error in postgresqlNewConnection(drv, ...) : 
  RPosgreSQL error: could not connect postgres@localhost:5432 on dbname "rdb": SCRAM authentication requires libpq version 10 or above

I tried solving this issue by updating the RPostgreSQL package, by adding path to libpq.dll file in system's environment variable aand few more things but in vain.

I also tried downloading the MS ODBC driver but can't see it in my start menu and when I try connecting the RStudio with PostgreSQL using ODBC driver I get following error

 con <- dbConnect(
+   odbc::odbc(),
+   driver = "PostgreSQL Unicode(x64) (psqlODBC)",
+   Server = "PostgreSQL 16",
+   Database = "rdb",
+   UID = rstudioapi::askForPassword("postgres"),
+   PWD = rstudioapi::askForPassword("shubhangi15"),
+   Port = 5432
+ )
Error: nanodbc/nanodbc.cpp:1135: IM002: [Microsoft][ODBC Driver Manager] Data source name not found and no default driver specified

Please help me with the solution for this.

0

There are 0 answers