tessl install tessl/pypi-sqlmodel@0.0.0SQLModel, SQL databases in Python, designed for simplicity, compatibility, and robustness.
Agent Success
Agent success rate when using this tile
85%
Improvement
Agent success rate improvement when using this tile compared to baseline
1x
Baseline
Agent success rate without this tile
85%
Build a hero team management system that efficiently loads hero-team relationships using different database query strategies.
Create a system that manages heroes and their teams with optimized relationship loading.
Define two database models:
Hero with fields: id (primary key), name (string), secret_name (string), and a relationship to teamTeam with fields: id (primary key), name (string), headquarters (string), and a relationship to heroesImplement the following functions in hero_manager.py:
get_hero_with_team_lazy(session, hero_id: int) - Retrieve a hero by ID. The team should be loaded on-demand when accessed (default behavior, no eager loading)get_team_with_heroes_joined(session, team_id: int) - Retrieve a team with all its heroes loaded in a single query using a SQL JOINget_all_teams_with_heroes_selectin(session) - Retrieve all teams and efficiently load their heroes in a second separate SELECT queryget_team_heroes_count(session, team_id: int) -> int - Return the count of heroes in a specific teamEach function should return the appropriate model instance(s) with relationships accessible as specified.
@generates
Provides SQL database operations with ORM and data validation support.