title: CSV to MSSQL using pymssql
body: <p>the motive is to continuously look for new records in my CSV and insert the records to the mssql using pymssql library.
  The CSV initially has 244 rows and I'm trying to insert 1 value and wants to dynamically insert the new row only when the script is ran with the scheduler.
  I have the script which runs every 15 seconds to insert the values, but post inserting the values the first time, the second time the script throws 'Cannot insert duplicate key in object' as I have my first column <code>DateID</code> which is set a PK and terminates the statement from the first record itself, therefore doesn't insert the new row.</p>
  <p>How do I encounter this.</p>
  <p>Code:</p>
  <pre><code>def trial():
      try: 
          for row in df.itertuples():
           
              datevalue = datetime.datetime.strptime(row.OrderDate, format)
  
              query= &quot;INSERT INTO data (OrderDate, Region, City, Category) VALUES (%s,%s,%s,%s)&quot;
              cursor.execute(query, (datevalue, row.Region,row.City,row.Category))
          print('&quot;Values inserted')
          conn.commit()
          conn.close()
      except Exception as e:
          print(&quot;Handle error&quot;, e)
          pass
          
  
  schedule.every(15).seconds.do(trial)
  </code></pre>
  <p>Library used: pymssql
  SQL: MSSQL server 2019</p>