Trouble sending PostgreSQL query in R Studio

Hello R people,
Please, I am trying to query a table that I created in PostgreSQL using the pgAdmin web interface. I created an empty table called "Actors", and attempted to write data into that table from R Studio.

dbWriteTable(con,"Actors",value = voice,overwrite = TRUE)

It appeared to be successful, because when I ran dbReadTable(conn = con,"Actors") I did get my populated table just as it is in the csv file.

However, when I try to query that table, I get an error message. Here is my code:

aquery <- dbSendQuery(conn = con,"SELECT movie,actor,character FROM Actors
                      WHERE movie = Aladdin")

Here is the error message:

Error: Failed to prepare query: ERROR:  relation "actors" does not exist
LINE 1: SELECT movie,actor,character FROM Actors

I don't understand why it is printing that message in my console, even though it seems I have done everything else right. I am new to PostgreSQL by the way.

Please, as always, I would greatly appreciate any helpful suggestion or advice. Thanks in advance of your help.

Here is the link to the dataset: https://docs.google.com/spreadsheets/d/1pcc6WB-bFKo5yEjgCKukPxkfmFSTaIC1fWr6OMPZc-E/edit?usp=sharing

This is not related to R but to a Postgresql peculiarity, all column and table names get converted to lowercase if not quoted.

Sorry, do you mean quoted in pgAdmin when creating the table or in R Studio?

I mean in any sql command you send to the database, like this one:

Which I think should be

SELECT movie, actor, character FROM "Actors"
                      WHERE movie = 'Aladdin'
1 Like

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.

If you have a query related to it or one of the replies, start a new topic and refer back with a link.