etlalchemy icon indicating copy to clipboard operation
etlalchemy copied to clipboard

Upsert() should function on tables w/o a PK

Open Anmol-Tuple opened this issue 7 years ago • 5 comments

Hi is there any method to remove only tables while upserting


Want to back this issue? Post a bounty on it! We accept bounties via Bountysource.

Anmol-Tuple avatar Jun 07 '17 05:06 Anmol-Tuple

Could you be a more specific? I'm not sure exactly what you mean...

seanharr11 avatar Jun 14 '17 22:06 seanharr11

Hi , when I am making drop_database=false each time the data is appending to the table thus making duplicates records

Anmol-Tuple avatar Jun 19 '17 07:06 Anmol-Tuple

Does the table with the duplicate records have a primary key? I believe we use the primary key of the table to determine whether a row should be updated or inserted.

seanharr11 avatar Jul 04 '17 01:07 seanharr11

what if it does not contain primary keys?

nitishxp avatar Aug 25 '17 10:08 nitishxp

There should be 2 fallback options if no primary keys are present on the table (in order):

  1. We gather all FKs, and use them as a "composite primary key" to upsert() on. This will be a common case when dealing with association tables (in many-to-many relations).
  2. We specify the columns that make up the "composite primary key", as a part of the config, for each table that does not have a primary key.

seanharr11 avatar Aug 28 '17 18:08 seanharr11