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

Batch inserts all fail if single row fails #105

Closed
alanault opened this issue Aug 20, 2018 · 3 comments
Closed

Batch inserts all fail if single row fails #105

alanault opened this issue Aug 20, 2018 · 3 comments

Comments

@alanault
Copy link

Hi,

I'm inserting a batch of 100 rows into a table using dbWriteTable. The table has a unique key to prevent duplicates and 1 of the rows I'm inserting is a duplicate to an existing entry.

In the RMySQL package, the 99 new rows would be correctly inserted, with a failure of the duplicate due to the unique constraint (although it did not return an error or warning).

However with RMariaDB, the entire insert fails, meaning no rows are added to the DB at all.

Is there a way to replicate the RMySQL behaviour or a work-around?

Many thanks

Alan

@s-fleck
Copy link

s-fleck commented Jan 16, 2019

Not a developer, but this would be the expected behaviour imho. Batch inserts should not partially insert datasets into relational databases (see wikipedia for "Atomicity" principle in database transcations)

@krlmlr
Copy link
Member

krlmlr commented Jan 26, 2019

Can you try the upsert features in the dbx package?

@krlmlr krlmlr closed this as completed Aug 25, 2020
@github-actions
Copy link

This old thread has been automatically locked. If you think you have found something related to this, please open a new issue and link to this old issue if necessary.

@github-actions github-actions bot locked and limited conversation to collaborators Aug 26, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants