Here's my code:
def delete_people(tname, del_name):
try:
with connection.cursor() as cursor:
del_ppl = 'DELETE FROM project3.%s WHERE id = %d; ALTER TABLE project3.%s DROP id; ' \
'ALTER TABLE project3.%s ADD id int UNSIGNED NOT NULL AUTO_INCREMENT PRIMARY KEY FIRST; ' \
'ALTER TABLE project3.%s AUTO_INCREMENT = 1;'
cursor.execute(del_ppl % (tname, del_name, tname, tname, tname, ))
connection.commit()
print('dltd sucsefuly')
except Exception as ex:
print("Connection refused...")
print(ex)
And when i try to launch this function, i always got this mistake:
(1064, "You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'ALTER TABLE project3.xcpsdojn DROP id; ALTER TABLE project3.xcpsdojn ADD id int ' at line 1")
I can't understand where's the mistake, because this exact code works in MySQL just fine. I'll appreciate your help!