Using Sqlalchemy
, I try to add a column
to a table
if it doesn't exist:
mytable = ticker +"data"
connection.execute("alter table " + mytable + " add column IF NOT EXISTS tokeep boolean;")
But I get this error:
sqlalchemy.exc.ProgrammingError: (pymysql.err.ProgrammingError) (1064, "You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'IF NOT EXISTS tokeep boolean' at line 1")
[SQL: alter table ABTdata add column IF NOT EXISTS tokeep boolean;]
(Background on this error at: https://sqlalche.me/e/14/f405)