diff options
author | emkael <emkael@tlen.pl> | 2014-10-17 16:56:44 +0200 |
---|---|---|
committer | emkael <emkael@tlen.pl> | 2014-10-17 16:56:44 +0200 |
commit | da87925da621f45ed72d8e3aa7b79d3d8eb9a0ca (patch) | |
tree | 7947f01248f2a49af1564231f7a09feb45c79b0e /f1elo/interface.py | |
parent | b45fdbeb10f8db7bd808954e3897292b3bc9d4f4 (diff) |
* DB generation from model metadata
Diffstat (limited to 'f1elo/interface.py')
-rw-r--r-- | f1elo/interface.py | 8 |
1 files changed, 8 insertions, 0 deletions
diff --git a/f1elo/interface.py b/f1elo/interface.py index 2065160..4b938ae 100644 --- a/f1elo/interface.py +++ b/f1elo/interface.py @@ -1,6 +1,8 @@ import datetime import dateutil.relativedelta +from sqlalchemy import MetaData + from f1elo.db import Session from f1elo.elo import Elo from f1elo.model import * @@ -10,6 +12,12 @@ class Interface: self.session = Session() self.date = date + def init_db(self, force=False): + from f1elo.model import Base + if force: + Base.metadata.drop_all(self.session.get_bind()) + Base.metadata.create_all(self.session.get_bind()) + def reset(self, date=None, _debug=False): if date is None: date = self.date |