📜  mysql 找到未读结果 - Python 代码示例

📅  最后修改于: 2022-03-11 14:46:09.648000             🧑  作者: Mango

代码示例2
/* If you looping through cursor & running another query,python no like*/
/* Store results into list first then loop again running query*/
/* So something like this*/

results = list()
for (id,fname,lname) in cursor:
    results.append({"id":id,"fname":fname,"lname":lname})
    
for r in results:
    id=r['id']
    query = ("update user set fname='whatever' where id = "+str(id))
    cursor.execute(query)
    cnx.commit()