Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add postgres update and upsert #1216

Closed
wants to merge 3 commits into from
Closed

Add postgres update and upsert #1216

wants to merge 3 commits into from

Conversation

StevenMMortimer
Copy link
Contributor

Add update and upsert functions for postgres connections. I haven't found a commonly accepted practice to updating or upserting many records into a PostgreSQL database from R. I can understand if this type of functionality should be rejected here and exists in RPostgres package. It was just not clear in its documentation that this functionality exists in via a parameterized query with dbBind or another function. The other alternative solution I've seen recommends repeating the query for each record to update, which doesn't seem as efficient as one large query as I've implemented

Link to stackoverflow solution: http://stackoverflow.com/questions/15099507/update-table-in-postgresql-database-through-r

Thanks for your consideration.

Introduce validation on the values parameter to be inserted into the database before constructing the SQL. This is a proposed solution to the issue #1214: #1214
Collapse the table argument with a period assuming that if it's a 2 character vector then the first element is the schema and the second is the table name in that schema
Add methods for postgres connections to accept update and upserts to tables based on data.frames passed to the command. This favors one large sql statement over repeating update statements per record.
@lock
Copy link

lock bot commented Jan 19, 2019

This old issue has been automatically locked. If you believe you have found a related problem, please file a new issue (with reprex) and link to this issue. https://reprex.tidyverse.org/

@lock lock bot locked and limited conversation to collaborators Jan 19, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

1 participant