小编Rub*_*amp的帖子

AttributeError:'MySQLCursor'对象没有属性'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()
Run Code Online (Sandbox Code Playgroud)

我收到以下错误:

AttributeError: 'MySQLCursor' object has no attribute 'commit'
Run Code Online (Sandbox Code Playgroud)

它是怎么来的,哪里出错了?我尝试连接MySQLWorkbench.

编辑: …

python mysql

5
推荐指数
1
解决办法
2万
查看次数

标签 统计

mysql ×1

python ×1