I am having trouble to execute following code, obviously these statement are part of the code.
cursor.execute("select max(propernoun_SRNO) from tblauto_tagged")
starting_index = cursor.fetchone()[0]
if starting_index == None :
starting_index = 1
ending_index = int(starting_index) +len(s)
i = 0
for j in range(starting_index,ending_index):
for i in range(0,len(s)):
c.append(nnp_array_index_coloumn.count(i))
add1 = add1 + c[i-1]
add2 = add1 + c[i]
cursor.execute("INSERT INTO tblauto_tagged(propernoun_SRNO,tagger,train,propernoun,propernoun_ID) VALUES (?,?,?,?,?)",(j,str(iput),str(corpora),str(nnp_array[add1:add2]),0))
for item in nnp_array_index_coloumn:
if item not in uniques:
uniques.append(item)
add1=0;add2=0
^{pr2}$Error generated is
I read previous attempts by different user to to solve the problem but for me nothing worked out.
mysql> repair table tblauto_tagged;
+--------------------------------+--------+----------+--------------------------------- ------------------------+
| Table | Op | Msg_type | Msg_text |
+--------------------------------+--------+----------+---------------------------------------------------------+
| collegedatabase.tblauto_tagged | repair | note | The storage engine for the table doesn't support repair |
+--------------------------------+--------+----------+---------------------------------------------------------+
1 row in set (0.00 sec)
mysql> select * from tblauto_tagged;
Empty set (0.00 sec)
After all of yours helpful suggestion I used following statement
cursor.execute("INSERT INTO tblauto_tagged(tagger,train,propernoun,propernoun_ID) VALUES (?,?,?,?)",(str(iput),str(corpora),str(nnp_array[add1:add2]),0))
And I ran into another trouble and for sure today is not my day.In order to make my problem more clear, I am editing the question with some additional information. ever thing works fine till propernoun_SRNO =149
mysql> select propernoun_SRNO ,tagger, train,propernoun,propernoun_ID from tblauto_tagged where propernoun_SRNO =149;
+-----------------+--------+-------+------------------------------------------------------------------------------------------------------------+---------------+
| propernoun_SRNO | tagger | train | propernoun | propernoun_ID |
+-----------------+--------+-------+------------------------------------------------------------------------------------------------------------+---------------+
| 149 | 1 | 1 | ['Wing', 'tank', 'Hopper', 'BU', 'crewmember', 'beam', 'injured', 'Drug', 'Serious', 'Marine', 'Incident'] | 0 |
+-----------------+--------+-------+------------------------------------------------------------------------------------------------------------+---------------+
and after propernoun_SRNO = 150 this is what I get.
mysql> select propernoun_SRNO ,tagger, train,propernoun,propernoun_ID from tblauto_tagged where propernoun_SRNO =150;
+-----------------+--------+-------+------------+---------------+
| propernoun_SRNO | tagger | train | propernoun | propernoun_ID |
+-----------------+--------+-------+------------+---------------+
| 150 | 1 | 1 | [] | 0 |
+-----------------+--------+-------+------------+---------------+
1 row in set (0.00 sec)
which goes all the way down to propernoun_SRNO = 22201
mysql> select max(propernoun_SRNO) from tblauto_tagged;
+----------------------+
| max(propernoun_SRNO) |
+----------------------+
| 22201 |
+----------------------+
1 row in set (0.00 sec)
mysql> select propernoun_SRNO ,tagger, train,propernoun,propernoun_ID from tblauto_tagged where propernoun_SRNO =22201;
+-----------------+--------+-------+------------+---------------+
| propernoun_SRNO | tagger | train | propernoun | propernoun_ID |
+-----------------+--------+-------+------------+---------------+
| 22201 | 1 | 1 | [] | 0 |
+-----------------+--------+-------+------------+---------------+
1 row in set (0.00 sec)
I don't know what the problem is but I think it needs some experts opinion. As mentioned in the previous comments should I use sequences, please advice
为了解释zerkms的注释:您试图插入一行,其中包含已经在使用的主键(
propernoun_SRNO
)的值。在如果您试图将所有新行插入数据库,请不要为主键指定值,MySQL应该自动计算一个值,假设列设置为
AUTO_INCREMENT
。在如果要用这些id替换现有行,请使用
REPLACE
而不是INSERT
,或者在插入新行之前删除现有行。在相关问题 更多 >
编程相关推荐