title: How can I prevent duplicate data storage in mysql?
body: <p>I have information about a car:</p>
  <pre><code>brand=&quot;bmw&quot;
  model = &quot;h256&quot;
  miles = &quot;22.35 mils&quot;
  year = 2017
  price= &quot;$22.35&quot;
  
  </code></pre>
  <p>I want to save this information in mysql database.
  So if this information does not exist in the database, it is stored.</p>
  <p>But I have a problem when inserting.
  I know that not exists should be used. But I do not know how to use not exists.
  Help me please.</p>
  <p>The code I have in mind:</p>
  <pre><code>c.execute('INSERT INTO mydata VALUES(&quot;%s&quot;,&quot;%s&quot;,&quot;%s&quot;,&quot;%i&quot;,&quot;%s&quot;) IF NOT EXISTS (SELECT * FROM mydata)'%(brand,model,miles,year,price))
  
  </code></pre>
  <p>At the top, I wrote the code I wanted, but that code is wrong.</p>
  <p>I have searched for this many times. But I did not find a clear answer.
  Help me please . for solving this problem</p>
  <p>Thanks a lot</p>