1

I need to write data to a postgres DB table using R. If a data exist for an ID in the table, data should be updated otherwise new data should append to the table.

I tried this using 'RPostgreSQL' Package I got this error message

dbWriteTable(con, 'credit', credit,overwrite=TRUE,row.names=FALSE,append=TRUE)<br>

Error in postgresqlWriteTable(conn, name, value, ...) :overwrite and append cannot both be TRUE

1 Answer 1

3

You cannot use overwrite and append at once. If use overwrite command as follows, it will truncate the table and rewrite the data.

dbWriteTable(con, 'credit', credit,overwrite=TRUE,row.names=FALSE)

If use append it will Add the rows. But it won't update your results.

dbWriteTable(con, 'credit', credit,row.names=FALSE,append=TRUE)
Sign up to request clarification or add additional context in comments.

1 Comment

Note that overwrite=TRUE drops and recreates the table rather than truncating.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.