I want to insert some items to mysql db.
When I did it in my python script, I got:
Error 1062: Duplicate entry '222' for key 'product_code'. product_code is an unique field.
When I did it in mysql command line, I got:
Error 1205(HY000):Lock wait timeout exceed; try restarting transaction.
Mysql is installed on win32; the table's engine is innodb.
code:
conn = mdb.connect(user = 'root', passwd = '[REMOVED]', db = 'vancl')
cur = conn.cursor()
sql2 = "insert into vancl.vancl_query1(product_code) values('100000')"
print sql2
cur.execute(sql2)
cur.close()
Your data will not be saved if you use a transaction engine like InnoDB because MySqlDb default to auto-commit off. To actually save data to database, you have to call commit