I have two tables in a PostgreSQL database; table1, table2. They both contain an id column. I want to add a column from table2, say col1, to table1 where table1.id = table2.id.
I am attempting to dot this via SQLalchemy. I keep getting the following error:
sqlalchemy.exc.ProgrammingError: (psycopg2.errors.SyntaxError) syntax error at or near "INNER"
Here is a snippet of the code:
engine = create_engine(...)
with engine.connect() as con:
con.execute("ALTER TABLE table1 ADD COLUMN col1 text")
con.execute("UPDATE table1 \
INNER JOIN table2 ON table1.id = table2.id \
SET table1.col1 = table2.col1")
Why am I getting this error?