diff options
| -rw-r--r-- | pysite/database.py | 9 | 
1 files changed, 9 insertions, 0 deletions
| 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, | 
