def ManageBreeders(): global cursor input = None while (input != '0'): print "--------------------- Breeders Menu -------------------------" print "1: dump the breeders table" print "2: create a breeder" print "3: modify a breeder" print "4: delete a breeder" print "0: return" input = raw_input("> ") if input == '1': BF.dump_table(cursor, "Breeders") elif input == '2': breeder_name = raw_input( "Enter breeder name > " ) city = raw_input("City > ") country = raw_input("Country > ") BF.Breeders.insert( cursor, breeder_name, city, country ) elif input == '3': breeder_name = raw_input( "Enter breeder name > " ) city = raw_input("City > ") country = raw_input("Country > ") BF.Breeders.update( cursor, breeder_name, city, country ) elif input == '4': breeder_name = raw_input( "Enter breeder name > " ) BF.Breeders.remove( cursor, breeder_name )
def ManageFish(): global cursor input = None while (input != '0'): print "--------------------- Breeders Menu -------------------------" print "1: dump the fish table" print "2: create a fish" print "3: modify a fish" print "4: delete a fish" print "0: return" input = raw_input("> ") if input == '1': BF.dump_table(cursor, "Fish") print_fish_view() if input == '2': breeder_name = raw_input( "Enter breeder name > " ) if not BF.Breeders.exists(cursor, breeder_name): print "\nBreeder %s does not exist in the database!"%(breeder_name) continue breed_name = raw_input( "Enter fish's breed name > " ) if not BF.Breeds.exists(cursor, breed_name): print "\nBreed %s does not exist in the database!"%(breed_name) continue purchase = raw_input("Enter date of purchase (YYYY-MM-DD) > ") BF.Fish.insert( cursor, breed_name, breeder_name, purchase ) elif input == '3': # modify print_fish_view() # if it is a GUI, then it is easy to provide pull down menu for # a valid selection of the tuple. fish_id = raw_input("Which fish to modify? (enter fish id) > ") ## check fish_id valid ?? breeder_name = raw_input( "Enter breeder name > " ) if not BF.Breeders.exists(cursor, breeder_name): print "\nBreeder %s does not exist in the database!"%(breeder_name) continue breed_name = raw_input( "Enter fish's breed name > " ) if not BF.Breeds.exists(cursor, breed_name): print "\nBreed %s does not exist in the database!"%(breed_name) continue purchase = raw_input("Enter date of purchase (YYYY-MM-DD) > ") BF.Fish.update( cursor, int(fish_id), breed_name, breeder_name, purchase ) elif input == '4': BF.Fish.remove( cursor, breed_name, breeder_name, purchase )
def ManageBreeds(): global cursor input = None while (input != '0'): print "--------------------- Breeders Menu -------------------------" print "1: dump the Breeds table" print "2: create a breed" print "3: modify a breed" print "4: delete a breed" print "0: return" input = raw_input("> ") if input == '1': BF.dump_table(cursor, "Breeds") if input == '2': # create breeder_name = raw_input( "Enter breeder's name > " ) if not Breeders.exists( cursor, breeder_name ): print breeder_name + " does not exist in database!" continue breed_type = raw_input( "Enter new breed's name > " ) creation = raw_input("Enter date of Creation (YYYY-MM-DD) > ") parent1 = raw_input("Enter breed's parent #1 > ") parent2 = "" if Breeders.hasBreed( cursor,breeder_name,parent1): parent2 = raw_input("Enter breed's parent #1 > ") if not Breeder.hasBreed( cursor,breeder_name,parent2): print "Can take parent#2, because %s does not has this breed."%(breeder_name) parent2 = "" else: print "Can take parent#1, because %s does not has this breed."%(breeder_name) parent1 = "" if parent1 == "" or parent2 == "": input = raw_input("Either parent is not owned for this breeder, do you still want to save the breed?[y/n]") if input == 'y': BF.Breeds.insert(cursor, breed_type, creation) else: BF.Breeds.insert( cursor, breed_type, creation, parent1, parent2) if input == '3': # modify breeder_name = raw_input( "Enter breeder's name > " ) if not BF.Breeders.exists( cursor, breeder_name ): print breeder_name + " does not exist in database!" continue breed_type = raw_input( "Enter the breed's name > " ) if not BF.Breeds.exists( cursor, breed_type ): print breed_type + " does not exist in database!" continue creation = raw_input("Enter date of Creation (YYYY-MM-DD) > ") parent1 = raw_input("Enter breed's parent #1 > ") parent2 = "" if BF.Breeders.hasBreed( cursor,breeder_name,parent1): parent2 = raw_input("Enter breed's parent #1 > ") if not Breeder.hasBreed( cursor,breeder_name,parent2): print "Can't take parent#2, because %s does not has this breed."%(breeder_name) parent2 = "" else: print "Can't take parent#1, because %s does not has this breed."%(breeder_name) parent1 = "" BF.Breeds.update( cursor, breed_type, creation, parent1, parent2) if input == '4': breed_type = raw_input("Enter breed type to remove > ") BF.Breeds.remove( cursor, breed_type )