def get_all_fishes(): conn = get_db_connection() rows = conn.execute( 'SELECT fishes.id, fishes.name,lifespan, mass, fishes.length, fishes.height, red, green, blue,' 'diets.name as diet,' 'fins.height as height_fin, fins.length as length_fin' ' FROM ((fishes JOIN colors ON color_id = colors.id)' 'JOIN diets ON diet_id = diets.id)' 'JOIN fins ON fin_id = fins.id').fetchall() fishes = [] for row in rows: fish = Fish() fish.id = row['id'] fish.name = row['name'] fish.mass = row['mass'] fish.diet = str2diet(row['diet']) fish.height = row['height'] fish.length = row['length'] fish.lifespan = row['lifespan'] fish.color = (row['red'], row['green'], row['blue']) fish.height_fin = row['height_fin'] fish.length_fin = row['length_fin'] fishes.append(fish) conn.close() return fishes
from fish import Fish from bird import Bird animal = Animal(animal_type='Horse') animal.breath() print() cat = Cat() cat.name = 'Sophie' cat.animal_type = 'Cat' cat.breath() cat.lick() print() fish = Fish() fish.name = 'Bret' fish.animal_type = 'Fish' fish.breath() fish.swim() print() bird = Bird() bird.name = 'Feathers' bird.animal_type = 'Bird' bird.breath() bird.fly() print() bird2 = Bird() bird2.animal_type = 'Bird' bird2.breath()