AttributeError: 'MySQLCursor' object has no attribute 'commit'
def fillblast(sequentie, titel_lijst, score_lijst, e_lijst, iden_lijst, pos_lijst, gaps_lijst):
conn = mysql.connector.connect(host = "ithurtswhenip.nl", user = "pg2", password = "pg2", database= "pg2", port= "3307")
cursor = conn.cursor()
Blast = 1000
for i in range(0,len(titel_lijst)):
Blast =+ 2
cursor.execute("INSERT INTO `pg2`.`Blast` (`Blast_id`, `Blast_seq`, `Blast_titel`, `Blast_score`, `Blast_E`, `Blast_gaps`, `Blast_pos`, `Blast_iden`) VALUES (%s, %s, %s, %s, %s, %s, %s, %s);", (Blast, sequentie[i] ,titel_lijst[i], score_lijst[i], e_lijst[i], iden_lijst[i], pos_lijst[i], gaps_lijst[i]))
print("1 record toegevoegd")
cursor.commit()
cursor.close()
conn.close()
I am getting the following error:
AttributeError: 'MySQLCursor' object has no attribute 'commit'
How does it happen, and where does it go wrong? I am trying to connect to MySQLWorkbench.
EDIT:
Now I am getting the following error:
mysql.connector.errors.DatabaseError: 1205 (HY000): Lock wait timeout exceeded; try restarting transaction
+3
Ruben Oldenkamp
source
to share
1 answer
Because you cannot fix the cursor! you must commit the connection.
# cursor.commit() --> This is wrong!
conn.commit() # This is right
Check documents ...
+8
FallenAngel
source
to share