Hi all!

I'm building a database of football stats. I have the following setup
right now:

class Game(Entity):
    using_options(tablename="games")
    rushing = OneToOne("Rushing", inverse="game")
    passing = OneToOne("Passing", inverse="game")

class Rushing(Entity):
    using_options(tablename="rushing")
    attempts = Field(Float)
    yards = Field(Float)
    game = ManyToOne("Game")
    yards_per_attempt = ColumnProperty(lambda c: c.yards/c.attempts)

class Passing(Entity):
    using_options(tablename="passing")
    attempts = Field(Float)
    yards = Field(Float)
    game = ManyToOne("Game")
    yards_per_attempt = ColumnProperty(lambda c: c.yards/c.attempts)

So, I'd like to add a ColumnProperty to Game that summed up rushing
and passing yards, something like,

    total_yards = ColumnProperty(lambda c: c.rushing.yards +
c.passing.yards)

Obviously, the above code doesn't work, but I'm curious if there's a
way to do it? Now, I could just write a `total_yards' method on Game
that sums everything up, but I like the idea of having it
automatically calculated once the table is defined. I'm new to
SQLAlchemy and elixir, so I'm hoping I'm just missing something
obvious :)

Any ideas?

(And thanks in advance!!)

-- 
You received this message because you are subscribed to the Google Groups 
"SQLElixir" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to 
[email protected].
For more options, visit this group at 
http://groups.google.com/group/sqlelixir?hl=en.

Reply via email to