summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authoremkael <emkael@tlen.pl>2016-11-30 13:42:37 +0100
committeremkael <emkael@tlen.pl>2016-11-30 13:42:37 +0100
commitcd1810a441230188b58d834e68cd15975a58cdb4 (patch)
treea5d7f2196e5cbe0c065a9872b9088b77eb02db22
parent4db7f7e6fd17764bd75e62d01039ab910f1be50f (diff)
* loading result SQL on DB init
-rw-r--r--f1elo/interface.py7
1 files changed, 7 insertions, 0 deletions
diff --git a/f1elo/interface.py b/f1elo/interface.py
index 6cca847..da1b77f 100644
--- a/f1elo/interface.py
+++ b/f1elo/interface.py
@@ -2,7 +2,9 @@ from __future__ import print_function
import datetime
import sys
+from os import path
+import __main__
import dateutil.relativedelta
from f1elo.db import Session
from f1elo.elo import Elo
@@ -21,6 +23,11 @@ class Interface:
if force:
Base.metadata.drop_all(self.session.get_bind())
Base.metadata.create_all(self.session.get_bind())
+ with open(path.join(path.dirname(__main__.__file__), 'sql', 'results.sql')) as result_dump:
+ for line in result_dump.readlines():
+ line = line.strip()
+ if line and line[0:2] != '--':
+ self.session.bind.execute(line)
def reset(self, date=None, _debug=False):
if date is None: