def populate_users(): # Generating Users print("GENERATING USERS") used = [] x = 0 while x < USER_AMOUNT: name = gen_name().rstrip(" ") if name not in used: used.append(name) x += 1 try: user = User( username=name, email=name + gen_email(), password=name, ) log = Logs(user=user) db.session.add(user) db.session.add(log) except Exception as _: pass db.session.commit()
def populate_users(): # Generating Users print("GENERATING USERS") used = [] for x in range(USER_AMOUNT): name = gen_name().rstrip(" ") if name not in used: used.append(name) try: user = User( username=name, email=name + gen_email(), password=bcrypt.generate_password_hash(name).decode( "utf-8"), ) log = Logs(user=user, ) db.session.add(user) db.session.add(log) if x % 5 == 0: db.session.commit() except Exception as _: pass db.session.commit()
"populate_db.prod: Skipping since, database is already populated!") exit() now_time = datetime.now(pytz.utc) admin_user = User( username="******", email=handle_admin_email(), password=handle_admin_pass(), isAdmin=True, ) db.session.add(admin_user) admin_log = Logs( user=admin_user, accountCreationTime=now_time, visitedMachine=True, machineVisitTime=now_time, ) db.session.add(admin_log) db.session.add(Settings(dummy=True)) populate_tags() populate_categories() populate_websites() db.session.commit() populate_challs() print("populate_db.prod: Database populated with some default data!")