From 6d752731dfd9b4b9fa983f6c6c6e02047641f92e Mon Sep 17 00:00:00 2001 From: Leon Sandøy Date: Mon, 16 Apr 2018 19:50:57 +0200 Subject: Adding some trace logging to the table init to figure out what's going wrong. --- pysite/database.py | 9 +++++++++ 1 file changed, 9 insertions(+) (limited to 'pysite/database.py') diff --git a/pysite/database.py b/pysite/database.py index 3ecdf53b..2603f125 100644 --- a/pysite/database.py +++ b/pysite/database.py @@ -78,13 +78,19 @@ class RethinkDB: :return: """ + self.log.debug("Initializing tables") initialized = {} for table, primary_key in ALL_TABLES.items(): + self.log.trace(f"Checking if {table} is empty.") + # If the table is empty if not self.pluck(table, primary_key): + self.log.trace(f"{table} appears to be empty. Checking if there is a json file at {os.getcwd()}" + f"pysite/database/table_init/{table}.json") + # And a corresponding JSON file exists if os.path.isfile(f"pysite/database/table_init/{table}.json"): @@ -92,6 +98,9 @@ class RethinkDB: with open(f"pysite/database/table_init/{table}.json") as json_file: table_data = json.load(json_file) + self.log.trace(f"Loading the json file into the table. " + f"The json file contains {len(table_data)} rows.") + for row in table_data: self.insert( table, -- cgit v1.2.3