Exemple #1
0
class User(db.Model):
    name = db.Column(db.String(120))
    email = db.Column(db.String(120), primary_key=True)
    password = db.Column(db.String(120), unique=True)
    role = db.Column(db.SmallInteger, default=USER.USER)
    status = db.Column(db.SmallInteger, default=USER.NEW)

    def __init__(self,
                 name=None,
                 email=None,
                 password=None,
                 role=None,
                 status=None):
        self.name = name
        self.email = email
        self.password = password
        self.role = role
        self.status = status

    def getStatus(self):
        return USER.STATUS[self.status]

    def getRole(self):
        return USER.ROLE[self.role]

    def __repr__(self):
        return '<User %r>' % self.email
class weather(db.Model):
    __tablename__ = 'weather'
    id = db.Column(db.Integer, primary_key=True)
    timestamp = db.Column(db.DateTime, default=datetime.utcnow())
    temp = db.Column(db.Integer, nullable=False)
    light = db.Column(db.Integer, nullable=False)

    def __repr__(self):
        return f"Weather('{self.timestamp}', '{self.temp}', '{self.light}')"
class logs(db.Model):
    __tablename__ = 'logs'
    id = db.Column(db.Integer, primary_key=True)
    name = db.Column(db.String(20), nullable=False, default='Rasp001')
    in_time = db.Column(db.DateTime, nullable=False, default=datetime.utcnow())
    user_id = db.Column(db.Integer, db.ForeignKey(accounts.id), nullable=False)

    def __repr__(self):
        return f"Device('{self.name}')"
class accounts(db.Model, UserMixin):
    __tablename__ = 'accounts'
    id = db.Column(db.Integer, primary_key=True)
    user = db.Column(db.String(20), unique=True, nullable=False)
    email = db.Column(db.String(120), unique=True, nullable=False)
    passwd = db.Column(db.String(120), nullable=False)
    usage = db.relationship('logs', backref='user_log', lazy=True)

    def __repr__(self):
        return f"User('{self.user}', '{self.email}')"
Exemple #5
0
def userdatamodel():
    return db.Table(
        'finance_stream',
        db.Column('user_email', db.String(120), db.ForeignKey('user.email')),
        db.Column('userinstitution_id', db.Integer,
                  db.ForeignKey('userinstitution.id')),
        db.Column('transaction_account', db.String(12),
                  db.ForeignKey('transaction.account')),
        db.Column('institution_id', db.Integer,
                  db.ForeignKey('institution.id')))
Exemple #6
0
class UserInstitution(db.Model):
    id = db.Column(db.Integer, primary_key=True)
    username = db.Column(db.String(80), unique=True)
    password = db.Column(db.String(255))
    institution = db.Column(db.Integer, db.Foreign_Key)

    def __init__(self, id=None, username=None, password=None):
        self.id = id
        self.username = username
        self.password = password

    def __repr__(self):
        return '<UserInstitutions %r>' % self.id
Exemple #7
0
class Institution(db.Model):
    id = db.Column(db.Integer, primary_key=True)
    org = db.Column(db.String(64), )
    url = db.Column(db.String(255), unique=True)
    brokerid = db.Column(db.String(255))

    def __init__(self, id, org, url, brokerid):
        self.id = id
        self.org = org
        self.url = url
        self.brokerid = brokerid

    def __repr__(self):
        return '<Institution %r>' % self.id
Exemple #8
0
class Transaction(db.Model):
    account = db.Column(db.String(12), primary_key=True)
    trntype = db.Column(db.String(20))
    date = db.Column(db.DateTime)
    amount = db.Column(db.Integer)
    name = db.Column(db.String(32))

    def __init__(self,
                 account=None,
                 trntype=None,
                 date=None,
                 amount=None,
                 name=None):
        self.account = account
        self.trntype = trntype
        self.date = date
        self.amount = amount
        self.name = name

    def __repr__(self):
        return '<Transaction %r>' % self.name