cursor.execute(
    """
      UPDATE animal SET name = %s
      WHERE name = %s
    """, (
    'snake', 'turtle'))
print('Number of rows updated: %d' % cursor.rowcount)
Python MySQL Parameterized Queries