Based on answers from this post: SQLAlchemy ON DUPLICATE KEY UPDATE
and the sqlalchemy documentation: https://docs.sqlalchemy.org/en/14/dialects/mysql.html#sqlalchemy