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