Python Forum
mysql id auto increment not working
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
mysql id auto increment not working
#1
I deleted ID 2 from mySQL db, but then I have the following to AUTO INCREMENT

import mysql.connector

mydb = mysql.connector.connect(
  host="localhost",
  user="root",
  password="password",
  database="Users"
)

mycursor = mydb.cursor()
SQL = "ALTER TABLE users MODIFY id INTEGER NOT NULL AUTO_INCREMENT"
mycursor.execute(SQL)
mydb.commit()
myresult = mycursor.fetchall()

for x in myresult:
    print(x)
But when I do this, it displays the database, but its not AUTO INCREMENT, ing. the ID goes from 1-3, it skips 2.
SQL = "SELECT * FROM users"
Output:
('Peter', 'Lowstreet 4', 1) ('Hannah', 'Mountain 21', 3) ('Michael', 'Valley 345', 4) ('Sandy', 'Ocean blvd 2', 5)
Reply


Messages In This Thread
mysql id auto increment not working - by tantony - Oct-18-2022, 02:29 PM

Possibly Related Threads…
Thread Author Replies Views Last Post
  Mysql and mysql.connector error lostintime 2 738 Oct-03-2023, 10:25 PM
Last Post: lostintime
  help to increment a third list hermine 7 1,393 Nov-29-2022, 04:19 PM
Last Post: perfringo
  Mysql error message: Lost connection to MySQL server during query tomtom 6 16,325 Feb-09-2022, 09:55 AM
Last Post: ibreeden
  Character Increment AnokhiRaaz 1 2,528 Apr-22-2021, 04:29 AM
Last Post: buran
  Increment text files output and limit contains Kaminsky 1 3,252 Jan-30-2021, 06:58 PM
Last Post: bowlofred
  Increment formula Kristenl2784 4 2,930 Jul-20-2020, 10:14 PM
Last Post: Kristenl2784
  [openpyxl] Increment cells being pasted into Template Kristenl2784 4 3,621 Jul-16-2020, 10:00 PM
Last Post: Kristenl2784
  How can I increment a List item with in a "for in" msteffes 4 3,614 Aug-14-2019, 08:55 AM
Last Post: DeaD_EyE
  How define iteration interval increment SriMekala 5 4,424 Jun-01-2019, 01:06 PM
Last Post: ichabod801
  SQlite3 quickly increment INT value? jmair 1 2,482 Mar-04-2019, 08:03 PM
Last Post: stranac

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020