class PsnPriceHistoryModel(DB.Model): """model for one of your table""" __tablename__ = 'psn_price_history' id = DB.Column(DB.Integer, primary_key=True) game_id = DB.Column(DB.String(), unique=True) game_title = DB.Column(DB.String()) chartPrices = DB.Column(JSON) chartBonusPrices = DB.Column(JSON) highest_price = DB.Column(DB.Float()) lowest_price = DB.Column(DB.Float()) plus_lowest_price = DB.Column(DB.Float()) def __init__(self, game_id=None, game_title=None, chartPrices=None, chartBonusPrices=None, highest_price=None, lowest_price=None, plus_lowest_price=None): self.game_id = game_id self.game_title = game_title self.chartPrices = chartPrices self.chartBonusPrices = chartBonusPrices self.highest_price = highest_price, self.lowest_price = lowest_price, self.plus_lowest_price = plus_lowest_price def __repr__(self): return '<PsnPriceHistoryModel: game_id {}>'.format(self.game_id)
class Login(DB.Model): id = DB.Column(DB.Integer, primary_key=True) name = DB.Column(DB.String(80), unique=True, nullable=False) email = DB.Column(DB.String(120), unique=True, nullable=False) def __repr__(self): return '<Login %r>' % self.name
class Location_DB(DB.Model): __tablename__ = 'locations' id = DB.Column(DB.Integer, primary_key=True) gid = DB.Column(DB.String(255), unique=True) # google id, api returns location with id name = DB.Column(DB.String(127)) address = DB.Column(DB.String(127)) phoneNumber = DB.Column(DB.String(50)) priceLevel = DB.Column(DB.Integer) rating = DB.Column(DB.Float) currentUserCount = DB.Column(DB.Integer) checkedInUsers = DB.relationship('User_DB', backref='currentLocation', lazy=True) # userList = [] # list to track the number of users at the location def __init__(self, gid="", name="", address="", phoneNumber="", priceLevel=-1, rating=-1): self.gid = gid self.name = name self.address = address self.phoneNumber = phoneNumber self.priceLevel = priceLevel self.rating = rating self.currentUserCount = 0 def __repr__(self): return '<location id {}>'.format(self.id)
class User(DB.Model): __tablename__ = "users" id = DB.Column(DB.Integer, primary_key=True) dt = DB.Column(DB.DateTime, nullable=False) username = DB.Column(DB.String(32), unique=True, nullable=False) pass_hash = DB.Column(DB.LargeBinary, nullable=False) public_key = DB.Column(DB.String(256), nullable=False) user_data = DB.Column(DB.Text, nullable=False) def __init__(self, username, pass_hash, public_key, user_data): self.dt = datetime.utcnow() self.username = username self.pass_hash = pass_hash self.public_key = public_key self.user_data = user_data def __repr__(self): return "<User %r>" % self.username def to_dict(self): return { "id": self.id, "dt": self.dt.isoformat(), "username": self.username, "pass_hash": self.pass_hash, "public_key": self.public_key, "user_data": self.user_data, }
class Person(DB.Model): ''' Initialize Person Table with ID/Email/Todos/Credentials Columns ''' id = DB.Column(DB.Integer, primary_key=True) email = DB.Column(DB.String(120), nullable=False) todos = DB.relationship('Todo', backref='person', lazy=True) cred = DB.Column(DB.PickleType) phone = DB.Column(DB.String(20))
class Team(DB.Model): """ Represents a team in our database :param uuid: the id of the team :param username: the username of the team :param password: the teams password :param balance: the balance of their account :param pub_key: public key for the jenkins builds :param private_key: key to identify teams """ __tablename__ = 'teams' uuid = DB.Column(DB.Integer, primary_key=True) username = DB.Column(DB.String(64)) password = DB.Column(DB.String(64)) balance = DB.Column(DB.Float()) pub_key = DB.Column(DB.String(2048)) private_key = DB.Column(DB.String(2048)) def __init__(self, uuid, username, password, balance, pub_key, private_key): self.uuid = uuid self.username = username self.password = password self.balance = balance self.pub_key = pub_key self.private_key = private_key def __repr__(self): return '<Team uuid={} balance={}>'.format(self.uuid, self.balance)
class Student(DB.Model, _ObjectWithFullName): """Класс для сущности 'Студент'""" __tablename__ = 'student' id = DB.Column('student_id', DB.BIGINT, primary_key=True) surname = DB.Column('student_surname', DB.String(45), nullable=False) firstname = DB.Column('student_firstname', DB.String(45), nullable=False) middlename = DB.Column('student_middlename', DB.String(45)) stud_group_id = DB.Column(DB.ForeignKey( 'stud_group.stud_group_id', ondelete='SET NULL', onupdate='SET NULL' ), index=True) semester = DB.Column('student_semestr', DB.SMALLINT) alumnus_year = DB.Column('student_alumnus_year', DB.SMALLINT) expelled_year = DB.Column('student_expelled_year', DB.SMALLINT) def __repr__(self): return "Student(id={id}," \ " surname={surname}," \ " firstname={firstname}," \ " middlename={middlename}," \ " stud_group_id={stud_group_id}," \ " semester={semester}," \ " alumnus_year={alumnus_year}," \ " expelled_year={expelled_year})". \ format(id=self.id, surname=self.surname, firstname=self.firstname, middlename=self.middlename, stud_group_id=self.stud_group_id, semester=self.semester, alumnus_year=self.alumnus_year, expelled_year=self.expelled_year)
class User(DB.Model): __tablename__ = 'users' id = DB.Column(DB.Integer, primary_key=True) dt = DB.Column(DB.DateTime, nullable=False) username = DB.Column(DB.String(32), unique=True, nullable=False) pass_hash = DB.Column(DB.String(60), nullable=False) public_key = DB.Column(DB.String(256), nullable=False) user_data = DB.Column(DB.Text, nullable=False) def __init__(self, username, pass_hash, public_key, user_data): self.dt = datetime.utcnow() self.username = username self.pass_hash = pass_hash self.public_key = public_key self.user_data = user_data def __repr__(self): return '<User %r>' % self.username def to_dict(self): return { 'id': self.id, 'dt': self.dt.isoformat(), 'username': self.username, 'pass_hash': self.pass_hash, 'public_key': self.public_key, 'user_data': self.user_data }
class LifegroupModel(DB.Model): __tablename__ = "lifegroups" name = DB.Column(DB.String(20), primary_key=True) email = DB.Column(DB.String(120), unique=True, nullable=False) password_hash = DB.Column(DB.String(100), nullable=False) notes = DB.relationship('NoteModel', backref='lifegroups', cascade="all, delete-orphan", passive_deletes=True) members = DB.relationship('MemberModel', backref='lifegroups', cascade="all, delete-orphan", passive_deletes=True) reset_password_code = DB.Column(DB.String(5), nullable=True) reset_password_timestamp = DB.Column(DB.DateTime, nullable=True) @property def password(self): raise AttributeError('password is a write only field') @password.setter def password(self, password): self.password_hash = BCRYPT.generate_password_hash(password).decode('utf-8') def check_password(self, password): return BCRYPT.check_password_hash(self.password_hash, password) def __repr__(self): return '<Lifegroup %r>' % self.name
class Contact(DB.Model): id = DB.Column(DB.Integer, primary_key=True) first_name = DB.Column(DB.String(255), nullable=False) last_name = DB.Column(DB.String(255)) number = DB.Column(DB.Integer, nullable=False) __table_args__ = (DB.UniqueConstraint('first_name', 'last_name', 'number'), ) @classmethod def create(cls, **kwargs): kwargs['number'] = _clean_phone_number(kwargs['number']) contact = Contact(**kwargs) DB.session.add(contact) DB.session.commit() return contact def serialize(self): return { 'id': self.id, 'first_name': self.first_name, 'last_name': self.last_name, 'number': _format_phone_number(self.number) } def delete(self): DB.session.delete(self) DB.session.commit() return {'success': True}
class TableDefintion(DB.Model): """ Main class """ id = DB.Column(DB.Integer, primary_key=True) email = DB.Column(DB.String(255)) address = DB.Column(DB.String(255)) price_low = DB.Column(DB.Integer) price_high = DB.Column(DB.Integer) city = DB.Column(DB.String(60)) state = DB.Column(DB.String(60)) purchase_type = DB.Column(DB.String(60)) def __init__(self, email, address, price_one, price_two, city, state, purchase_type): self.email = email self.address = address self.price_low = price_one self.price_high = price_two self.city = city self.state = state self.purchase_type = purchase_type def __repr__(self): return ("<The address is %s, the price is between %d and %d.>" % self.address % self.price_range_low % self.price_range_high)
class Transaction(DB.Model): """ Represents a transaction :param uuid: the id of the transaction :param time: the timestamp this session was created :param src: who initiated the transaction :param dst: who the transaction is to :param desc: a description of the transaction :param amount: the amount the transaction is for """ __tablename__ = 'transactions' uuid = DB.Column(DB.Integer, primary_key=True, autoincrement=True) time = DB.Column(DB.DateTime, default=datetime.datetime.utcnow) src = DB.Column(DB.String(64)) dst = DB.Column(DB.String(64)) desc = DB.Column(DB.String(128)) amount = DB.Column(DB.Integer) def __init__(self, src=None, dst=None, desc=None, amount=None): self.src = src self.dst = dst self.desc = desc self.amount = amount def __repr__(self): return '<Transaction uuid={} time={} src={} dst={} amount={} desc={}>'.format( self.uuid, self.time, self.src, self.dst, self.amount, self.desc)
class Org(DB.Model): id = DB.Column(DB.Integer, primary_key=True, autoincrement=True) name = DB.Column(DB.String(128)) address = DB.Column(DB.String(4096)) def __repr__(self): return self.name
class TokenModel(DB.Model): __tablename__ = "tokens" id = DB.Column(DB.String(), primary_key=True) jti = DB.Column(DB.String(36), nullable=False) lifegroup = DB.Column(DB.String(20), nullable=False) expired_on = DB.Column(DB.DateTime, nullable=False) created_on = DB.Column(DB.DateTime)
class NoteModel(DB.Model): __tablename__ = "notes" id = DB.Column(DB.String(), primary_key=True) lifegroup = DB.Column(DB.String(20), DB.ForeignKey('lifegroups.name', ondelete='CASCADE'), nullable=False) text = DB.Column(DB.String(), nullable=False) def __repr__(self): return '<Note %r>' % self.id
class User(DB.Model, UserMixin): id = DB.Column(DB.Integer, primary_key=True) email = DB.Column(DB.String(255), unique=True) password = DB.Column(DB.String(255)) active = DB.Column(DB.Boolean()) confirmed_at = DB.Column(DB.DateTime()) roles = DB.relationship('Role', secondary=roles_users, backref=DB.backref('users', lazy='dynamic'))
class Account(DB.Model): id = DB.Column(DB.Integer, primary_key=True, autoincrement=True) org_id = DB.Column(DB.Integer, DB.ForeignKey("org.id"), nullable=False) name = DB.Column(DB.String(128)) code = DB.Column(DB.String(128)) def __repr__(self): return "%s - %s" % (self.code, self.name)
class FavoriteMeal(DB.Model): __tablename__ = 'favoritemeal' meal_id=DB.Column(DB.Integer, unique=True, nullable=False, primary_key=True) googleId = DB.Column(DB.String(120), ForeignKey('user.googleId')) link = DB.Column(DB.String(500), unique=False, nullable=False) image = DB.Column(DB.String(500), unique=False, nullable=False) label = DB.Column(DB.String(500), unique=False, nullable=False) def __repr__(self): return '<FavoriteMeal %r>' % self.googleId
class Person(db.Model): id = db.Column(db.Integer, primary_key=True) username = db.Column(db.String(80), unique=True, nullable=False) email = db.Column(db.String(120), unique=True, nullable=False) def __repr__(self): return '<Person %r>' % self.username def __init__(self, username, email): self.username = username self.email = email
class FavoriteWorkout(DB.Model): __tablename__ = 'favoriteworkout' workout_id=DB.Column(DB.Integer, unique=True, nullable=False, primary_key=True) googleId = DB.Column(DB.String(120), ForeignKey('user.googleId')) name = DB.Column(DB.String(300), unique=True, nullable=False) desc = DB.Column(DB.String(500), unique=True, nullable=False) muscle_group = DB.Column(DB.String(100), unique=True, nullable=False) # equipment_name = DB.Column(DB.String(120), unique=True, nullable=False) def __repr__(self): return '<FavoriteWorkout %r>' % self.googleId
class Posts(DB.Model): """columns for post table""" id = DB.Column(DB.Integer, primary_key=True) itemname = DB.Column(DB.String(225)) imageurl = DB.Column(DB.String(225)) pricehist = DB.Column(DB.String(400)) username = DB.Column(DB.String(225)) pfp = DB.Column(DB.String(225)) time = DB.Column(DB.String(225)) likes = DB.Column(DB.Integer) graphurl = DB.Column(DB.String(225)) asin = DB.Column(DB.String(225)) minprice = DB.Column(DB.Integer) maxprice = DB.Column(DB.Integer) varianceprice = DB.Column(DB.Integer) meanprice = DB.Column(DB.Integer) currprice = DB.Column(DB.String(225)) def __init__(self, username, pfp, time, itemname, imageurl, pricehist, likes, graphurl, asin, minprice, maxprice, meanprice, varianceprice, currprice): self.username = username self.pfp = pfp self.time = time self.itemname = itemname self.imageurl = imageurl self.pricehist = pricehist self.likes = likes self.graphurl = graphurl self.asin = asin self.minprice = minprice self.maxprice = maxprice self.meanprice = meanprice self.varianceprice = varianceprice self.currprice = currprice
class education(DB.Model): """Simple database model to track event attendees.""" __tablename__ = 'education' unitid = DB.Column(DB.String(100), primary_key=True) opeid = DB.Column(DB.String(100)) opeid6 = DB.Column(DB.String(100)) instnm = DB.Column(DB.String(100)) city = DB.Column(DB.String(100)) state = DB.Column(DB.String(100)) insturl = DB.Column(DB.String(100)) sat_avg = DB.Column(DB.String(100)) graddebt = DB.Column(DB.String(100)) def __init__(self, unitid=None, opeid=None, opeid6=None, instnm=None, city=None, state=None, insturl=None, sat_avg=None, graddebt=None): self.unitid = unitid self.opeid = opeid self.opeid6 = opeid6 self.instnm = instnm self.city = city self.state = state self.insturl = insturl self.sat_avg = sat_avg self.graddebt = graddebt
class Guest(DB.Model): """Simple database model to track event attendees.""" __tablename__ = 'guests' id = DB.Column(DB.Integer, primary_key=True) name = DB.Column(DB.String(80)) email = DB.Column(DB.String(120)) def __init__(self, name=None, email=None): self.name = name self.email = email
class MemberModel(DB.Model): __tablename__ = "members" id = DB.Column(DB.String(), primary_key=True) lifegroup = DB.Column(DB.String(), DB.ForeignKey('lifegroups.name', ondelete='CASCADE')) name = DB.Column(DB.String(), nullable=False) seats = DB.Column(DB.Integer(), default=0) suburb = DB.Column(DB.String(), nullable=False) def __repr__(self): return '<Member %r>' % self.name
class ChatLog(DB.Model): # pylint: disable=too-few-public-methods # pylint: disable=no-member id = DB.Column(DB.Integer, primary_key=True) content = DB.Column(DB.String(200)) user = DB.Column(DB.String(120)) picture_url = DB.Column(DB.String(200)) def __init__(self, content, user, picture_url): self.content = content self.user = user self.picture_url = picture_url
class Score(DB.Model): """ Model for a user and corresponding score value. keyword """ id = DB.Column(DB.Integer, primary_key=True) name = DB.Column(DB.String(30), nullable=False) scoreValue = DB.Column(DB.String(30), nullable=False) def __repr__(self) -> str: return "<Name: {}>".format(self.name)
class Group(Base): __tablename__ = 'auth_group' name = DB.Column(DB.String(128), nullable=False, unique=True) initials = DB.Column(DB.String(10), nullable=False, unique=True) parent_id = DB.Column(DB.Integer, DB.ForeignKey('auth_group.id'), nullable=True) children = DB.relationship('Group', lazy="joined", join_depth=2) roles = DB.relationship('Role', secondary=ROLES, backref=DB.backref('groups'))
class User(db.Model): __tablename__ = 'users' id = db.Column(db.Integer, primary_key=True) username = db.Column(db.String(30)) email = db.Column(db.String(50)) password = db.Column(db.String(50)) def __init__(self, username, password, email): self.username = username self.email = email self.password = password self.created_at = datetime.datetime.now()
class Player(DB.Model): ''' Table that holds id, email, username, score, and profile_image Email is unique ''' id = DB.Column(DB.Integer, primary_key=True) email = DB.Column(DB.String(255), unique=True, nullable=False) username = DB.Column(DB.String(80), unique=False, nullable=False) score = DB.Column(DB.Integer, unique=False, nullable=False) profile_image = DB.Column(DB.String(255), unique=False, nullable=False) def __repr__(self): return '<Player %r>' % self.email
class Articles(DB.Model): __tablename__ = 'articles' id = DB.Column(DB.Integer, primary_key=True) title = DB.Column(DB.String(225)) author = DB.Column(DB.String(100)) body = DB.Column(DB.String()) create_date = DB.Column(DB.DateTime, default=datetime.now) def __init__(self, title=None, author=None, body=None): self.title = title self.author = author self.body = body