title: How can I do upsert (update and insert) query in MySQL Python?
body: <p>I'm looking for a simple upsert (Update/Insert).</p>
  
  <p>I have table in which I am inserting rows for books table but next time when I want to insert row I don't want to insert again data for that table just want to update with required columns if it exits there if not then create new row.</p>
  
  <p>How can I do this in Mysql-python?</p>
  
  <pre><code>cursor.execute("""INSERT INTO books (book_code,book_name,created_at,updated_at) VALUES (%s,%s,%s,%s)""", (book_code,book_name,curr_time,curr_time,))
  </code></pre>