1

The error messages I get from RPostgreSQL contain nonsense characters where there should be some informative text. Here are two examples:

Example 1: Querying a non-existent table

> library("RPostgreSQL")
Loading required package: DBI
>  drv <- dbDriver("PostgreSQL")
>  connection <- dbConnect(
+      drv,
+      dbname="postgres",
+      host=db_host,
+      port=5432,
+      user=.pguser,
+      password=.pgpass
+      )
>
> results <- dbGetQuery(connection, "SELECT * FROM t1")
Error in postgresqlExecStatement(conn, statement, ...) :
  RS-DBI driver: (�W��J)
Warning message:
In postgresqlQuickSQL(conn, statement, ...) :
  Could not create execute: SELECT * FROM t1 LIMIT 20

Example 2: Attempting to connect to a database with invalid credentials.

> library("RPostgreSQL")
Loading required package: DBI
>  drv <- dbDriver("PostgreSQL")
> connection <- dbConnect(
+      drv,
+      dbname="postgres",
+      host=db_host,
+      port=5432,
+      user=.pguser,
+      password=.pgpass
+      )
Error in postgresqlNewConnection(drv, ...) : RS-DBI driver: (8�)

I would like to see an error message instead of RS-DBI driver: (�W��J) or RS-DBI driver: (8�). What is going on here? How can I see the complete error message?

7
  • 1
    What encoding are you using? Is it English, Latin, or some other language? Is the encoding on your computer, in R, RStudio, and this database the same? For example, to test my theory, I changed the encoding in R to ru_RU.KOI8-R (non-UTF-8 formatting) and intentionally made an erroneous query with POSTgreSQL. The error message was gibberish. When I changed it to ru_RU.UTF-8 (a Russian and UTF-compliant alternative), my messages were no longer gibberish. Before: ��������������: and after: Предупреждение: (That just means warning.) Commented Dec 9, 2022 at 4:56
  • That's a good thought but I checked and the encodings are all English. Commented Dec 12, 2022 at 18:49
  • Are they English and UTF-8 (I'm not sure if it can there is an English that isn't UTF-8, but I'd hate to assume!) How about the database and server? How about the computer? Is it all the same encoding? Commented Dec 12, 2022 at 22:17
  • What OS is your device? I'm guessing it's Windows? Can you let me know about your OS, your server version, and your version of the r package RPostgreSQL? Commented Dec 12, 2022 at 22:23
  • The setup is a little complicated, R and Postgres are running on Linux (Redhat 8.7) servers but I access them using BitVise (using a terminal to run R and Rscript) or Chrome (for RStudio) running on Windows 10. The character encoding for Postgres, Linux and R is en_US.UTF-8. The version of RPostgeSQL is 0.7-3. PostgreSQL is version 14.6. R is version 4.2.2. The charter encoding for Windows is iso-8859-1 and for BitVise it is UTF-8. Thank you for your help! Commented Dec 13, 2022 at 18:30

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.