Answer the question
In order to leave comments, you need to log in
Why autoincrement increases but new lines in the table do not appear?
Hello, I am using the mysql library in python, making a normal connection. When I try to execute a SELECT query, everything works, but when I execute an INSERT query, the table's auto-increment increases, but no new elements appear in the table.
Table structure:
A method that works great with SELECT queries:
def query(self, db, query, values=False):
if values:
cursor = db.cursor(prepared=True)
cursor.execute(query, values)
else:
cursor = db.cursor()
cursor.execute(query)
result = []
for data in cursor:
result.append(data)
return result
result2 = self.query(db, 'INSERT INTO admins (user_id, password) VALUES (%s, %s)', [id, new_password])
Answer the question
In order to leave comments, you need to log in
db.commit() must be done
And auto-increment is atomic - it grows even if the transaction is rolled back
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question