diff options
Diffstat (limited to 'f1elo/model.py')
-rw-r--r-- | f1elo/model.py | 11 |
1 files changed, 11 insertions, 0 deletions
diff --git a/f1elo/model.py b/f1elo/model.py index 4b893dc..7865198 100644 --- a/f1elo/model.py +++ b/f1elo/model.py @@ -85,5 +85,16 @@ class Ranking(Base): def __repr__(self): return ("%s: %0.2f (%s)" % (self.driver.__repr__().decode('utf8'), self.ranking, self. rank_date)).encode('utf8') +def find_driver(name, country, session): + driver = session.query(Driver).filter(Driver.driver==name).first() + if driver: + return driver + else: + driver = Driver() + driver.driver = name + driver.country = country + session.add(driver) + return driver + __all__ = ['Driver', 'Entry', 'Ranking', 'Race', 'RaceType'] |