I have a database in PostgreSQL which is named DATA in all caps. When I try to write an R data.frame to this database using RPostgreSQL like so:
library(RPostgreSQL)
con <- dbConnect(PostgreSQL(), host="myhost",
user= "postgres", password="myPass", dbname="DATA")
dbWriteTable(con, "test", myDf)
I get the following error:
Error in postgresqlExecStatement(conn, statement, ...) :
RS-DBI driver: (could not Retrieve the result : ERROR: no schema has been selected to create in
)
[1] FALSE
However I notice that if I go to Postgresql and change the database name to data (lower case) and then change the script to call dbname="data" then it works like a charm.
I looked through the documentation for rPostgreSQL and the only mention of case I saw had to do with field names being case sensitive.
So my questions are:
- Is this behavior is expected?
- In my situation I control the DB so I can rename the database at will. How would I work around this behavior if I could not rename the database to all lower case?