Пример #1
0
class User(DB.Model):
    """User database model"""
    __tablename__ = 'users'

    id = DB.Column(DB.Integer,
                   nullable=False,
                   autoincrement=True,
                   primary_key=True)
    username = DB.Column(DB.String(80), unique=True, nullable=False)
    email = DB.Column(DB.String(120), nullable=False)
    password_hash = DB.Column(DB.String(64), nullable=False)
    create_date = DB.Column(DB.DateTime,
                            nullable=False,
                            default=datetime.utcnow)
    items = DB.relationship('Item', backref='user', lazy=True)
Пример #2
0
class PlayerSession(DB.Model):
    """Player->Game session database model"""
    __tablename__ = 'playersession'
    id = DB.Column(DB.Integer,
                   nullable=False,
                   autoincrement=True,
                   primary_key=True)
    username = DB.Column(DB.String(64), nullable=False)
    session_key = DB.Column(DB.String(8), nullable=False)
    buzz_time = DB.Column(DB.DateTime, nullable=True)
    game_id = DB.Column(DB.Integer,
                        DB.ForeignKey(Game.__tablename__ + '.id',
                                      ondelete='CASCADE'),
                        nullable=False)
    is_creator = DB.Column(DB.Boolean, nullable=False, default=False)
Пример #3
0
class Game(DB.Model):
    """Game database model"""
    __tablename__ = 'game'
    id = DB.Column(DB.Integer,
                   nullable=False,
                   autoincrement=True,
                   primary_key=True)
    game_ext_id = DB.Column(DB.String(8), nullable=False)
    q_num = DB.Column(DB.Integer, nullable=False, default=0)
Пример #4
0
class Account(DB.Model):
    """Account database model"""
    __tablename__ = 'accounts'
    id = DB.Column(DB.Integer,
                   nullable=False,
                   autoincrement=True,
                   primary_key=True)
    device_key = DB.Column(DB.String(350), nullable=False)
    create_date = DB.Column(DB.DateTime,
                            nullable=False,
                            default=datetime.utcnow)
Пример #5
0
class Location(DB.Model):
    """Location database model"""
    __tablename__ = 'locations'

    id = DB.Column(DB.Integer,
                   nullable=False,
                   autoincrement=True,
                   primary_key=True)
    name = DB.Column(DB.String(120), nullable=False)
    user_id = DB.Column(DB.Integer,
                        DB.ForeignKey(User.__tablename__ + '.id'),
                        nullable=False)
Пример #6
0
class Event(DB.Model):
    """Event database model"""
    __tablename__ = 'events'
    id = DB.Column(DB.Integer,
                   nullable=False,
                   autoincrement=True,
                   primary_key=True)
    latitude = DB.Column(DB.Float(precision=32, asdecimal=True),
                         nullable=False)
    longitude = DB.Column(DB.Float(precision=32, asdecimal=True),
                          nullable=False)
    account_id = DB.Column(DB.Integer,
                           DB.ForeignKey(Account.__tablename__ + '.id',
                                         ondelete='CASCADE'),
                           nullable=False)
    time = DB.Column(DB.DateTime, nullable=False)
    group_size_max = DB.Column(DB.Integer, nullable=False)
    group_size_min = DB.Column(DB.Integer, nullable=False)
    title = DB.Column(DB.String(50), nullable=False)
    category = DB.Column(DB.String(50), nullable=False)
    description = DB.Column(DB.String(140), nullable=False)
    create_date = DB.Column(DB.DateTime,
                            nullable=False,
                            default=datetime.utcnow)