title: mysql.connector.errors.IntegrityError: 1062 (23000): Duplicate entry '3' for key 'PRIMARY'
body: <p><a href="https://i.stack.imgur.com/X69a6.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/X69a6.png" alt="enter image description here" /></a><em><strong>I Have a Problem with this code Here</strong></em></p>
  <p>I Have An ids on my Table and Its Primary key and set to Auto Increment</p>
  <pre><code>def register():
  
      if (t1.get()==&quot;&quot;  or t2.get()==&quot;&quot; or t3.get()==&quot;&quot;):
          messagebox.showinfo(&quot;Result&quot;,&quot;Please Complete the Provided Details!&quot;)
  
      else:
          databases = mysql.connector.connect(
          host =&quot;localhost&quot;,
          user = &quot;userdata&quot;,
          password = &quot;&quot;,
          database = &quot;facerecog&quot;
          )
  
          cursors = databases.cursor()
          cursors.execute(&quot;SELECT * from record&quot;)
          result = cursors.fetchall()
  </code></pre>
  <p><strong>Heres My Id set</strong></p>
  <pre><code>id = 2 #This is the ID That I set 
  </code></pre>
  <p>for x in result:</p>
  <pre><code>  id ++1 #auto increment from my python
      sql = &quot;INSERT INTO record(ids,names,course_year,positions) values(%s, %s ,%s , %s)&quot;
      val = (id, t1.get(), t2.get(), t3.get())
      cursors.execute(sql,val)
      databases.commit()
  </code></pre>
  <p><strong>The Error I get</strong></p>
  <pre><code>mysql.connector.errors.IntegrityError: 1062 (23000): Duplicate entry '3' for key 'PRIMARY'
  </code></pre>
  <p><strong>How Can I auto_increment it?</strong></p>