我正在尝试在MySQL表中一次插入多个行。
我希望该声明插入公告的等级,如果该公告已经具有等级,它将对其进行更新
req = "INSERT INTO announcements_reputation (announcement_id,
rank, rank_score) VALUES(%s, %s, %s) ON DUPLICATE KEY UPDATE
rank=%s"
ranked_announcements = [(14322, 1, 228.95, 1), (14021, 2, 150.95,
2)]
cursor.executemany(req, ranked_announcements)
我希望它对列表的每个元组执行该语句,并用每个元组项填充每个%s