Python:MySQL DELETE问题

时间:2014-07-27 02:46:42

标签: python mysql python-2.7

我正在尝试从包含2列的表中删除值; twitchname

这是代码:

cur2 = db.cursor()
cur2.execute("SELECT twitch FROM Alan45wmzYGCc5C7TIMCdczrel.whitelist WHERE twitch NOT IN(SELECT twitch FROM Alan45wmzYGCc5C7TIMCdczrel.followers)")
result = cur2.fetchall()
db.commit()

for row in result:
    unfollowers.extend(row[0])
    unfollowers_join = '\n'.join(unfollowers)
    print unfollowers_join

cur3 = db.cursor()
for x in follows:
    cur3.execute("DELETE FROM Alan45wmzYGCc5C7TIMCdczrel.whitelist WHERE twitch = (%s);", (x,))
data_unfollower = (unfollowers_join)
db.commit()

result是需要删除的值,而resultcur2查询,用于查找不匹配的值。

0 个答案:

没有答案