title: Insert or update if exists in mysql using pandas
body: <p>I am trying to insert data from xlsx file into mysqdl table. I want to insert data in table and if there is a duplicate on primary keys, I want to update the existing data otherwise insert. I have written the script already but I realized it is too much work and using pandas it is quick. How can I achieve it in pandas?</p>
  
  <pre><code>#!/usr/bin/env python3
  
  import pandas as pd
  import sqlalchemy
  
  engine_str = 'mysql+pymysql://admin:mypass@localhost/mydb'
  engine = sqlalchemy.create_engine(engine_str, echo=False, encoding='utf-8')\
  
  file_name = "tmp/results.xlsx"
  df = pd.read_excel(file_name)
  </code></pre>