ankane / dbx

A fast, easy-to-use database library for R
Other
187 stars 15 forks source link

dbxUpsert - Error: ON CONFLICT clause does not match any PRIMARY KEY or UNIQUE constraint #25

Closed janush1985 closed 3 years ago

janush1985 commented 3 years ago

Hello,

Well done on this phenomenal package. Cheers!

I am unable to get following code to work:

`db <- dbxConnect(adapter="sqlite", dbname="my database") table <- "forecasts" DBI::dbCreateTable(db, table, data.frame(id=1:3, temperature=20:22))

records <- data.frame(id=c(3, 4), temperature=c(20, 25)) dbxUpsert(db, table, records, where_cols=c("id")) `

I get following error msg:

"Error: ON CONFLICT clause does not match any PRIMARY KEY or UNIQUE constraint"

Other functions such as dbxUpdate, dbxInsert are working ok.

Help much appreciated!

Best, Janush

ankane commented 3 years ago

Hey @janush1985, that error is coming from SQLite. You'll need to make sure the columns in where_cols (id in this case) have either a primary key or unique constraint.

janush1985 commented 3 years ago

Hi man,

Thanks a lot for the tip. Much appreciated.

All the best!