def select_all(): zombie_types = [] sql = "SELECT * FROM zombie_types" results = run_sql(sql) for result in results: zombie_type = ZombieType(result["name"], result["id"]) zombie_types.append(zombie_type) return zombie_types
zombie_repository.delete_all() zombie_type_repository.delete_all() human_1 = Human("Rochelle") human_repository.save(human_1) human_2 = Human("Coach") human_repository.save(human_2) human_3 = Human("Nick") human_repository.save(human_3) human_4 = Human("Ellis") human_repository.save(human_4) zombie_type_1 = ZombieType("Walker") zombie_type_repository.save(zombie_type_1) zombie_type_2 = ZombieType("Crawler") zombie_type_repository.save(zombie_type_2) zombie_type_3 = ZombieType("Runner") zombie_type_repository.save(zombie_type_3) zombie_1 = Zombie("Ed", zombie_type_2) zombie_repository.save(zombie_1) zombie_2 = Zombie("Pete", zombie_type_1) zombie_repository.save(zombie_2) biting_1 = Biting(human_2, zombie_2)
def select(id): sql = "SELECT * FROM zombie_types WHERE id = %s" values = [id] result = run_sql(sql, values)[0] zombie_type = ZombieType(result["name"], result["id"]) return zombie_type
def update_zombie(id): name = request.form["name"] zombie_type = ZombieType(name, id) zombie_type_repository.update(zombie_type)
def create_zombie_type(): name = request.form["name"] new_zombie_type = ZombieType(name) zombie_type_repository.save(new_zombie_type) return redirect("/zombietypes")