[R-sig-DB] append=TRUE, overwrite=FALSE ignored in dbWriteTable

Tomoaki NISHIYAMA tomo@k|n @end|ng |rom kenroku@k@n@z@w@-u@@c@jp
Thu Oct 27 12:05:07 CEST 2011


Hi,

Ok, back to the mailing list.

If I understand correctly, you are using RpgSQL (note this is one of the most important information)
and it appears that RpgSQL does not match to the specification of DBI. 
http://cran.r-project.org/web/packages/DBI/index.html

The definition in RpgSQL is something like
setMethod("dbWriteTable", "pgSQLConnection", def=function(conn, name, value, overwrite=TRUE, ...) {
and does NOT have append argument.
In addition, the default value of overwrite differs to the DBI spec.
In DBI the spec is
  dbWriteTable(conn, name, value, row.names = T, ...,
              overwrite = F, append = F)

This discrepancy is perhaps inherited from RJDBC.
There was a similar report early this year.
https://stat.ethz.ch/pipermail/r-sig-db/2011q1/000996.html

So, I Cc:ed this mail to the maintainers of RpgSQL and RJDBC.

You can modify the respective source code
RpgSQL/R/class.R
as you like, or use RPostgreSQL.
Using RPostgreSQL on windows is not very easy, though.
-- 
Tomoaki NISHIYAMA

Advanced Science Research Center,
Kanazawa University,
13-1 Takara-machi, 
Kanazawa, 920-0934, Japan


On 2011/10/27, at 18:07, Elinor Zeev wrote:

> orry, I misunderstood, I am pretty new to using R,
> I got the libraries using add packages and the Greece mirror
> the version of the driver is      RJDBC      "GPL-2"            "2.13.2"
> 
> On Thu, Oct 27, 2011 at 1:49 AM, Tomoaki NISHIYAMA <tomoakin using kenroku.kanazawa-u.ac.jp> wrote:
> Hi,
> 
> I am asking for the *driver* version, not the PostgreSQL version.
> 
> What library do you load and how do you connect?
> 
> http://cran.r-project.org/web/packages/RPostgreSQL/index.html
> http://cran.r-project.org/web/packages/RpgSQL/index.html
> -- 
> Tomoaki NISHIYAMA
> 
> Advanced Science Research Center,
> Kanazawa University,
> 13-1 Takara-machi, 
> Kanazawa, 920-0934, Japan
> 
> 
> On 2011/10/27, at 17:33, Elinor Zeev wrote:
> 
>> version PostgreSQL 9.1,
>>  
>> the append does not work, and I  get an error;
>>   Error in .local(conn, name, value, ...) : 
>>   Table `region_subgroup_mktseg' already exists
>>  
>> Thank you
>> 
>> On Wed, Oct 26, 2011 at 4:41 PM, Tomoaki NISHIYAMA <tomoakin using kenroku.kanazawa-u.ac.jp> wrote:
>> Hi,
>> 
>> Can you tell the PostgreSQL driver version?
>> 
>> BTW,
>> dbWriteTable(con, "region_subgroup_mktseg", results_tograph,  append=TRUE)
>> should work without prior check for dbExistTable.
>> --
>> Tomoaki NISHIYAMA
>> 
>> Advanced Science Research Center,
>> Kanazawa University,
>> 13-1 Takara-machi,
>> Kanazawa, 920-0934, Japan
>> 
>> 
>> On 2011/10/27, at 7:58, Elinor Zeev wrote:
>> 
>> > Hello,
>> > Within a bigger loop, I want to write results to a table in Postgress,
>> >
>> > the overwrite and append arguments are ignored and I end up with only the
>> > current data in the table and the older data is overwritten.
>> > My code is;
>> >
>> > ifelse((dbExistsTable(con, "region_subgroup_mktseg")),
>> > dbWriteTable(con, "region_subgroup_mktseg", results_tograph,  append=TRUE,
>> > overwrite=FALSE),
>> > dbWriteTable(con, "region_subgroup_mktseg", results_tograph))
>> >
>> > R.version
>> >               _
>> > platform       i386-pc-mingw32
>> > arch           i386
>> > os             mingw32
>> > system         i386, mingw32
>> > status
>> > major          2
>> > minor          13.2
>> > year           2011
>> > month          09
>> > day            30
>> > svn rev        57111
>> > language       R
>> > version.string R version 2.13.2 (2011-09-30)
>> >
>> > Thank you
>> >
>> >       [[alternative HTML version deleted]]
>> >
>> > _______________________________________________
>> > R-sig-DB mailing list -- R Special Interest Group
>> > R-sig-DB using r-project.org
>> > https://stat.ethz.ch/mailman/listinfo/r-sig-db
>> >
>> 
>> 
> 
> 




More information about the R-sig-DB mailing list