def db_sync(): try: print("Syncing with database...") db_sessions = data.load_sessions_from_db() print("...loaded sessions from database...") file_sessions = data.load_sessions_from_file() data.write_sessions_to_db(file_sessions) print("...wrote sessions to database.") for session in db_sessions: session.save() with open('data/sync_history', 'w') as f: f.write("{}\n".format(time())) except Exception as e: print("Failed to connect with the database.")
def set_user(self, user): self.user = user User.set_default(user) self.open_questions = data.by_type( data.open_questions(data.load_sessions_from_file(),self.user) )