python
unknown
plain_text
2 years ago
438 B
4
Indexable
import conn from conn import Animals, session class Animal: def __init__(self, name, age): self.name = name self.age = age def add_to_database(self, animal): animal = [vars(animal)] session.add_all(Animals(**animal) for animal in animal) return session.commit() # bunny = Animal('Ruda', 5) # # bunny.add_to_database(bunny) horsey = Animal('Siwy', 10) horsey.add_to_database(horsey)
Editor is loading...