From 13d2a09b7f925430671d5c4aa19a1573784d2d3d Mon Sep 17 00:00:00 2001 From: Mark Cheese <35660089+omfgitsmark@users.noreply.github.com> Date: Thu, 19 Mar 2020 14:41:24 -0400 Subject: [PATCH] Commit bug fix (#51) --- mtgsqlive/json2sql.py | 14 ++++---------- 1 file changed, 4 insertions(+), 10 deletions(-) diff --git a/mtgsqlive/json2sql.py b/mtgsqlive/json2sql.py index 4cbcee2..4cb5bbe 100644 --- a/mtgsqlive/json2sql.py +++ b/mtgsqlive/json2sql.py @@ -47,6 +47,10 @@ def execute(input_file, output_file, extras=False) -> None: build_sql_schema(json_data, output_file) parse_and_import_cards(json_data, input_file, output_file) parse_and_import_extras(input_file, output_file) + if output_file["path"].suffix == ".sql": + output_file["handle"].write("COMMIT;") + else: + output_file["handle"].commit() output_file["handle"].close() @@ -396,11 +400,6 @@ def parse_and_import_cards( ) sql_dict_insert(set_translation_attr, "set_translations", output_file) - if output_file["path"].suffix == ".sql": - output_file["handle"].write("COMMIT;") - else: - output_file["handle"].commit() - def parse_and_import_extras(input_file: pathlib.Path, output_file: Dict) -> None: """ @@ -488,11 +487,6 @@ def parse_and_import_extras(input_file: pathlib.Path, output_file: Dict) -> None output_file, ) - if output_file["path"].suffix == ".sql": - output_file["handle"].write("COMMIT;") - else: - output_file["handle"].commit() - def sql_insert_all_card_fields( card_attributes: Dict[str, Any], output_file: Dict