【发布时间】:2012-06-15 02:13:14
【问题描述】:
我想在 mysql db 中插入一些项目。
当我在我的 python 脚本中这样做时,我得到了:
错误 1062:密钥“product_code”的条目“222”重复。 product_code 是一个唯一字段。
当我在 mysql 命令行中执行此操作时,我得到:
Error 1205(HY000):Lock wait timeout超过;尝试重启事务。
mysql安装在win32上;表的引擎是 innodb。
代码:
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()
【问题讨论】:
-
也许是锁的问题...我现在连那张桌子都放不下。
-
现在,我重新创建一个与上一个相同的表。在脚本中,没有报错,但实际上没有插入数据。在命令行中,插入 sql 效果很好。
-
不幸的是我的python经验有限,所以这里必须有人插话。
标签: python mysql mysql-error-1062 mysql-error-1205