title: How do i prevent duplicate entries to a table in mysql and python
body: <p>I'm making a script which inserts data into a MySQL Database and I need to only insert Data once a day from multiple sensors each but I can't find a way to prevent multiple entries. Is there a way to check if the entry exists and if it doesn't only then insert the data?
  Here is the part of my code which contains a syntax error.
  Sorry if the mistake is obvious, I'm new to SQL.</p>
  
  <pre><code> mycursor.execute('''
          SELECT * FROM MotorControlDB.FSYesterdayVolume
          IF Date = %s AND DeviceID = %s THEN
            INSERT INTO MotorControlDB.FSYesterdayVolume(DeviceID, VolumeYesterday, Date)
            VALUES (%s, '%s', '%s')
          END IF
          ''', (YesterdayDate, '2-ES-WC-FS', '2-ES-WC-FS', EastVolumeYesterday, YesterdayDate))
  </code></pre>