diff options
author | emkael <emkael@tlen.pl> | 2017-01-04 00:14:28 +0100 |
---|---|---|
committer | emkael <emkael@tlen.pl> | 2017-01-04 20:56:17 +0100 |
commit | 970e12912cb139527753fce2709144deed1c764a (patch) | |
tree | 0fc29b3a0b78abfd8a723c8c6f3d719669ed91b6 /ausbutler | |
parent | 0338652f859808c108b23f2e7d9d187dd400e00e (diff) |
Model classes
Diffstat (limited to 'ausbutler')
-rw-r--r-- | ausbutler/model.py | 47 |
1 files changed, 47 insertions, 0 deletions
diff --git a/ausbutler/model.py b/ausbutler/model.py new file mode 100644 index 0000000..c237359 --- /dev/null +++ b/ausbutler/model.py @@ -0,0 +1,47 @@ +from sqlalchemy import Column, ForeignKey, MetaData, Table +from sqlalchemy.ext.declarative import declarative_base +from sqlalchemy.types import Float, Integer +from .db import Session + +Base = declarative_base() +session = Session() + +class AusButler(Base): + __tablename__ = 'aus_butler' + id = Column(Integer, primary_key=True) + match = Column(Integer, primary_key=True) + segment = Column(Integer, primary_key=True) + score = Column(Float) + cut_score = Column(Float) + opp_score = Column(Float) + corrected_score = Column(Float) + board_count = Column(Integer) + + def __repr__(self): + return '[%d] %d-%d: %.2f-%.2f=%.2f' % (self.id, + self.match, self.segment, + self.score or 0.0, + self.opp_score or 0.0, + self.corrected_score or 0.0) + +class Butler(Base): + __table__ = Table('butler', MetaData(bind=session.bind), + Column('id', Integer, primary_key=True), + autoload=True) + +class Score(Base): + __table__ = Table('scores', MetaData(bind=session.bind), + Column('rnd', Integer, primary_key=True), + Column('segment', Integer, primary_key=True), + Column('tabl', Integer, primary_key=True), + Column('room', Integer, primary_key=True), + Column('board', Integer, primary_key=True), + autoload=True) + +class Segment(Base): + __table__ = Table('segments', MetaData(bind=session.bind), + Column('rnd', Integer, primary_key=True), + Column('segment', Integer, primary_key=True), + Column('tabl', Integer, primary_key=True), + autoload=True) + |