()
| 5 | |
| 6 | |
| 7 | def create_heroes(): |
| 8 | with Session(engine) as session: |
| 9 | team_z_force = Team(name="Z-Force", headquarters="Sister Margaret's Bar") |
| 10 | |
| 11 | hero_deadpond = Hero( |
| 12 | name="Deadpond", secret_name="Dive Wilson", team=team_z_force |
| 13 | ) |
| 14 | session.add(hero_deadpond) |
| 15 | session.commit() |
| 16 | |
| 17 | session.refresh(hero_deadpond) |
| 18 | |
| 19 | print("Created hero:", hero_deadpond) |
| 20 | print("Hero's team:", hero_deadpond.team) |
| 21 | |
| 22 | |
| 23 | def main(): |