writing tables to Postgresql using rPostgreSQL when the database name is all capital letters

后端 未结 1 1326
故里飘歌
故里飘歌 2021-02-15 11:29

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:

lib         


        
1条回答
  •  日久生厌
    2021-02-15 11:49

    There were definitely issues with tables in upper-case. In think we handle that now: Try quoting it as "DATA" and it should go through. Unquoted table identifier all get lower-cased.

    Your issue is having the entire database in uppercase. It may also work with quoting, maybe even with '\"DATA\"' as an argument to dbConnect.

    Otherwise, reproducible examples on the list are best, and with some luck, Tomoaki will find a fix for your problem.

    Oh, and we spell it like the package: RPostgreSQL with capital arrrrrrr, especially today on talk like a piRate day.

    Edit: Looks like there is simply no issue with current versions on Ubuntu 11.04:

    First, create DATA

    edd@max:~$ createdb DATA
    edd@max:~$ psql DATA
    psql (8.4.8)
    Type "help" for help.
    
    DATA=# \q
    edd@max:~$ 
    

    Second, and in R, connect and save some data:

    R> library(RPostgreSQL)
    R> con <- dbConnect(PostgreSQL(), host="localhost", user= "edd", 
    +                   password=".....", dbname="DATA")
    R> con
     
    R> dbWriteTable(con, "quicktest", cars)
    [1] TRUE
    R> 
    

    Third, check for content in DATA:

    DATA=# select * from quicktest limit 5;
     row_names | speed | dist 
    -----------+-------+------
     1         |     4 |    2
     2         |     4 |   10
     3         |     7 |    4
     4         |     7 |   22
     5         |     8 |   16
    (5 rows)
    
    DATA=# 
    

    Looking good to me.

    0 讨论(0)
提交回复
热议问题