I want to write to a table in a PostgreSQL database that has a
BIGSERIAL
auto-incrementing primary key. Rather than creating key values in R and passing them to PostgreSQL, I want PostgreSQL to handle that itself.
This problem is cross-posted from
Stack Overflow where you can find code to reproduce the issue. A
comment there pointed me to this group.
An
older post on this group contains a patch to make
postgresqlWriteTable only write columns that exist in the
data frame. The thread got rather long and confused, and while it was implied that the patch had been committed, it doesn't seem to have made it into mainline RPostgreSQL. The thread also hinted that there may be better ways deal with this, but they weren't explicitly mentioned.
I believe that the ability to let PostgreSQL handle auto-incrementing primary keys (and the more general feature of only copying some columns of a table from R to the database) is very useful. Is my enhanced version of the original path worthy of inclusion into RPostgreSQL, or is there a better way of doing things? Either way, I think that this issue is important enough to revisit.