cur.execute("""SELECT match_own_goals.game_id, home_team, away_team, team, time FROM football.match_own_goals JOIN football.match_info ON match_own_goals.game_id = match_info.game_id""")
e = cur.fetchall()
for game in e:
print game
time = game[4]
if game[3] == 1:
team_id = game[1]
else:
team_id = game[2]
cur.execute("""UPDATE football.match_own_goals SET team_id = %s WHERE game_id = %s AND time = %s""", (team_id, game[0], time))
db.commit()
在应该更新的 108 行中,它只更新了大约 10 行,我不知道为什么会这样。它提取 SELECT 语句中的所有信息。这可能很明显,但已经晚了哈哈。
Team 是 1 或 2,最初表示主场或客场
谢谢