I have a short SQL script which "copies" selected columns from a SQL table from one id (main_id=1
) to two other ids (main_id=3
and 4
) of the same table.
There are also some other ids which are part of the primary key of the table.
The script works fine using a PostgreSQL DB. However, i would like to replace this using SQLAlchemy ORM, but i don't know how to do this.
UPDATE "MyTable" AS T
SET "Varname_1" = Cell."Varname_1",
"Varname_2" = Cell."Varname_2"
FROM "MyTable" AS Cell
WHERE T.id_A = Cell.id_A AND
T.id_B = Cell.id_B AND
Cell.main_id = 1 AND
T.main_id IN (3, 4);
Can anyone help me to "translate" this?