From 0d08bb8b9213ab03a334596f7e6f2630d26d79a3 Mon Sep 17 00:00:00 2001 From: Zach Halpern Date: Wed, 18 Sep 2019 21:35:17 -0400 Subject: [PATCH] translations may be non-existent Signed-off-by: Zach Halpern --- mtgsqlive/json2sql.py | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/mtgsqlive/json2sql.py b/mtgsqlive/json2sql.py index fac3da4..b6402be 100644 --- a/mtgsqlive/json2sql.py +++ b/mtgsqlive/json2sql.py @@ -299,7 +299,7 @@ def parse_and_import_cards( token_attr = handle_token_row_insertion(token, set_code) sql_dict_insert(token_attr, "tokens", sql_connection) - for language, translation in set_data["translations"].items(): + for language, translation in set_data.get("translations", {}).items(): LOGGER.debug("Inserting set_translation row for {}".format(language)) set_translation_attr = handle_set_translation_row_insertion( language, translation, set_code @@ -326,7 +326,7 @@ def parse_and_import_cards( token_attr = handle_token_row_insertion(token, set_code) sql_dict_insert(token_attr, "tokens", sql_connection) - for language, translation in set_data["translations"].items(): + for language, translation in set_data.get("translations", {}).items(): LOGGER.debug("Inserting set_translation row for {}".format(language)) set_translation_attr = handle_set_translation_row_insertion( language, translation, set_code @@ -336,7 +336,6 @@ def parse_and_import_cards( ) sql_connection.commit() - def sql_insert_all_card_fields( card_attributes: Dict[str, Any], sql_connection: sqlite3.Connection ) -> None: