I have two tables, Table A
and Table B
. I have added one column to Table A
, record_id
. Table B
has record_id
and the primary ID for Table A
, table_a_id
. I am looking to deprecate Table B
.
Relationships exist between Table B
's table_a_id
and Table A
's id
, if that helps.
Currently, my solution is:
db.execute("UPDATE table_a t
SET record_id = b.record_id
FROM table_b b
WHERE t.id = b.table_a_id")
This is my first time using this ORM -- I'd like to see if there is a way I can use my Python models and the actual functions SQLAlchemy gives me to be more 'Pythonic' rather than just dumping a Postgres statement that I know works in an execute call.