From ab82ec00edb48c0996ad31b8982f285be55db8c2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Maximilian=20Ke=C3=9Fler?= Date: Sat, 6 May 2023 23:51:26 +0200 Subject: [PATCH] insert into seeds db before into games --- download_data.py | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/download_data.py b/download_data.py index b8870e1..da0d957 100644 --- a/download_data.py +++ b/download_data.py @@ -81,18 +81,18 @@ def export_game(game_id) -> [bool, bool]: with conn.cursor() as cur: # cur.execute("UPDATE seeds SET deck=(%s) WHERE seed=(%s);", (deck, seed)) - cur.execute( - "INSERT INTO games (id, num_players, score, seed, variant_id, deck_plays, one_extra_card, one_less_card, all_or_nothing, actions)" - "VALUES (%s, %s, %s, %s, %s, %s, %s, %s, %s, %s)", - (game_id, num_players, game.score, seed, var_id, deck_plays, one_extra_card, one_less_card, all_or_nothing, compressed_actions)) cur.execute( "INSERT INTO seeds (seed, num_players, variant_id, deck)" "VALUES (%s, %s, %s, %s)" "ON CONFLICT (seed) DO NOTHING", (seed, num_players, var_id, compressed_deck) ) + cur.execute( + "INSERT INTO games (id, num_players, score, seed, variant_id, deck_plays, one_extra_card, one_less_card, all_or_nothing, actions)" + "VALUES (%s, %s, %s, %s, %s, %s, %s, %s, %s, %s)", + (game_id, num_players, game.score, seed, var_id, deck_plays, one_extra_card, one_less_card, all_or_nothing, compressed_actions)) conn.commit() return True, not any([deck_plays, one_extra_card, one_less_card, all_or_nothing]) if __name__ == "__main__": - export_game(960753) + export_game(961092)