class Article(db.Model): __tablename__ = 'article' article_id = db.Column(db.Integer, primary_key=True, autoincrement=True) auther = db.Column(db.Integer, db.ForeignKey('user.user_id')) title = db.Column(db.String(64)) article_img = db.Column(db.String(64)) #文章图片 brief = db.Column(db.Text) content = db.Column(db.Text) publish_time = db.Column(db.DateTime) #发布时间 label_id = db.Column(db.Integer, db.ForeignKey('label.label_id')) #文章标签 read_quantity = db.Column(db.Integer, default=0) # 文章阅读量 like_number = db.Column(db.Integer, default=0) # 文章点赞数 def to_dict(self): dic = { 'article_id': self.article_id, 'auther': self.auther, 'title': self.title, } return dic @staticmethod def isReadArticle(): return True
class Question(db.Model): __tablename__ = 'question' id = db.Column(db.Integer(), primary_key=True) ques_id = db.Column(db.String(255)) question = db.Column(db.String(255000)) answer = db.Column(db.String(255000)) know = db.Column(db.String(255000)) level = db.Column(db.String(255000)) def __init__(self,ques_id,question,answer,level,know): self.ques_id = ques_id self.question = question self.answer = answer self.level = level self.know = know def get_ques_id(self): return self.ques_id def get_question(self): return self.question def get_answer(self): return self.answer def get_id(self): return self.id def get_know(self): return self.know def get_level(self): return self.level
class User(db.Model): __tablename__ = 'user' username = db.Column(db.String(50), primary_key=True) password = db.Column(db.String(80), nullable=False) email = db.Column(db.String(120), nullable=False) player_type = db.Column(db.String(25), nullable=False, default='player') avatar = db.Column(db.Text, default='') created_date = db.Column(db.DateTime, nullable=False, default=datetime.datetime.utcnow()) stats = db.relationship('Stats', backref=db.backref('user'), uselist=False) followed = db.relationship( 'User', secondary=followers, primaryjoin=(followers.c.follower_username == username), secondaryjoin=(followers.c.followed_username == username), backref=db.backref('followers', lazy='dynamic'), lazy='dynamic') def follow(self, user): if not self.is_following(user): self.followed.append(user) def unfollow(self, user): if self.is_following(user): self.followed.remove(user) def is_following(self, user): return self.followed.filter( followers.c.followed_username == user.username).count() > 0 def followed_an_followers(self): return list(map(lambda u: u.username, self.followed.all())), list( map(lambda u: u.username, self.followers.all()))
class Videos(db.Model): id = db.Column(db.Integer, unique=True, primary_key=True) title = db.Column(db.String(80), nullable=False) link = db.Column(db.String(200), nullable=False) def __repr__(self): return '<vid %r>' % self.id
class ClassyJob(db.Model): __tablename__ = 'classy_jobs' id = db.Column(db.Integer, primary_key=True) name = db.Column(db.String(1000)) s3bucket = db.Column(db.String(1000)) texts = db.relationship("ClassyText") labels = db.relationship("ClassyLabel")
class GroundTruth(db.Model): _tablename__ = 'ground_truth' id = Column(db.Integer(), primary_key=True) user_id = Column(db.Integer(), ForeignKey('user.id')) course_id = course_id = db.Column(db.String(255)) course_name = db.Column(db.String(255)) choice = db.Column(db.String(255)) gt = db.Column(db.Integer()) def __init__(self, user_id, course_id, course_name, choice, gt): self.user_id = user_id self.course_id = course_id self.course_name = course_name self.choice = choice self.gt = gt def get_user_id(self): return self.user_id def get_course_id(self): return self.course_id def get_course_name(self): return self.course_name def get_choice(self): return self.choice def get_gt(self): return self.gt def set_user_id(self,user_id): self.user_id = user_id def set_course_id(self,course_id): self.course_id = course_id def set_course_name(self,course_name): self.course_name = course_name def set_choice(self,choice): self.choice = choice def set_gt(self,gt): self.gt = gt
class DataOfficerUnknown(db.Model): __bind_key__ = COPA_DB_BIND_KEY __tablename__ = 'data_officerunknown' id = db.Column(db.Integer, nullable=True, primary_key=True) data_officerallegation_id = db.Column(db.Integer) age = db.Column(db.String(50)) gender = db.Column(db.String(1), nullable=True) race = db.Column(db.String(50), nullable=True) years_on_force = db.Column(db.String(50)) created_at = db.Column(db.DateTime, nullable=False, default=datetime.utcnow) updated_at = db.Column(db.DateTime, nullable=False, default=datetime.utcnow) def __repr__(self): return f'<id: {self.id}, ' \ f'data_officerallegation_id: {self.data_officerallegation_id}, ' \ f'age: {self.age}, ' \ f'gender: {self.gender}, ' \ f'race: {self.race}, ' \ f'years_on_force: {self.years_on_force}, ' \ f'created_at: {self.created_at}, ' \ f'updated_at: {self.updated_at}, ' \ f'>'
class Games(db.Model): id = db.Column(db.Integer, unique=True, primary_key=True) nick = db.Column(db.String(20), nullable=False) name = db.Column(db.String(20), nullable=False) dis = db.Column(db.String(200), nullable=False) def __repr__(self): return '<game %r>' % self.id
class User(db.Model): __tablename__ = 'users' id = db.Column(db.Integer, primary_key=True) name = db.Column(db.String(200)) email = db.Column(db.String(200), index=True, unique=True) def __repr__(self): return '<User %r>' % (self.name)
class Phone(db.Model): __tablename__ = "phone" id = db.Column(db.Integer, primary_key=True, autoincrement=True) model = db.Column(db.String(32)) price = db.Column(db.String(32)) company_name = db.Column( db.String(20), db.ForeignKey('company.name')) # 创建与company.name关联的外键 company = db.relationship("Company", backref="phone_of_company")
class Company(db.Model): __tablename__ = "company" name = db.Column(db.String(20), primary_key=True) location = db.Column(db.String(20)) def __repr__(self): return "name:{0} location:{1}".format(self.name, self.location)
class User(db.Model): __tablename__ = 'users' user = db.Column(db.String(240), primary_key=True) name = db.Column(db.String(240)) def __repr__(self): return '<User %r>' % (self.name)
class Video(db.Model): __tablename__ = 'video' vid = db.Column(db.Integer, primary_key=True) vtitle = db.Column(db.String(100), nullable=False) savename = db.Column(db.String(100)) vcontent = db.Column(db.String(500), nullable=True) up_date = db.Column(db.Date) hits = db.Column(db.Integer, default=0) user_id = db.Column(db.Integer, db.ForeignKey('user.user_id'))
class Follower(db.Model): __tablename__ = 'followers' id = db.Column(db.Integer, primary_key=True) user = db.Column(db.String(240)) followed_nickname = db.Column(db.String(240)) def __repr__(self): return '<Followers %r>' % (self.followed)
class Service(db.Model): id = db.Column(db.Integer, primary_key=True) name = db.Column(db.String(100), unique=True, nullable=False, default='') description = db.Column(db.String(255), nullable=True, default='') admin_items = db.relationship('AdminItem', backref='service', lazy=True) client_items = db.relationship('ClientItem', backref='service', lazy=True) user_services = db.relationship("UserService", backref='service', lazy=True)
class Image(db.Model): __tablename__ = "image" id = db.Column(db.Integer, primary_key=True) label = db.Column(db.String(32)) picture = db.Column(db.String(32)) time = db.Column(db.DATETIME) description = db.Column(db.TEXT) def __repr__(self): return self.label
class HubD(db.Model): __tablename__ = 'hub' id = db.Column(db.Integer, primary_key=True) location = db.Column(db.String(120), index=True, unique=True) sequence = db.Column(db.String(1000), index=True, unique=True) def __repr__(self): object = {'location': self.location, 'sequence': self.sequence} return json.dumps(object)
class ImagesUpload(db.Model): '''图片上传表''' __tablename__ = 'imagesupload' id = db.Column(db.Integer, primary_key=True, autoincrement=True) uploader = db.Column(db.Integer, db.ForeignKey('user.user_id'), nullable=False) #图片所属用户 id imagename = db.Column(db.String(64)) imagebrief = db.Column(db.String(128)) #图片简介 imagetime = db.Column(db.DateTime, nullable=False)
class Email(db.Model): '''contains details of all emails sent''' id = db.Column(db.Integer, primary_key=True) to_addr_list = db.Column(db.String(80), unique=True, nullable=False) cc_addr_list = db.Column(db.String(120), unique=True, nullable=False) subject = db.Column(db.String(80), unique=True, nullable=False) message = db.Column(db.Text, unique=True, nullable=False) def __repr__(self): return '<Email %r>' % self.message
class UserService(db.Model): id = db.Column(db.Integer, primary_key=True) user_id = db.Column(db.Integer, db.ForeignKey('user.id'), nullable=False) service_id = db.Column(db.Integer, db.ForeignKey('service.id'), nullable=False) name = db.Column(db.String(100), nullable=False, default='') project_name = db.Column(db.String(100), nullable=False, default='') a_items = db.relationship('AItem', backref='user_service', lazy=True) c_items = db.relationship('CItem', backref='user_service', lazy=True)
class Posts(db.Model): id = db.Column(db.Integer, unique=True, primary_key=True) title = db.Column(db.String(200), nullable=False) content = db.Column(db.String(600), nullable=False) date = db.Column(db.DateTime, default=datetime.now) author = db.Column(db.String(200), nullable=False) image = db.Column(db.String(30)) def __repr__(self): return '<post %r>' % self.id
class User(db.Model): __tablename__ = 'user' 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) password = db.Column(db.String(80), nullable=False) events = db.relationship('Events', backref='author', lazy=True) def __repr__(self): return 'User {} and Id {}'.format(self.username, self.id)
class Rating(db.Model): __tablename__ = 'ratings' id = db.Column(db.Integer, primary_key=True) user = db.Column(db.String(240)) rating = db.Column(db.Float) date = db.Column(db.String(240)) def __repr__(self): return '<Rating %r>' % (self.rating)
class Message(db.Model): __tablename__ = 'messages' id = db.Column(db.Integer, primary_key=True) user = db.Column(db.String(240)) mes = db.Column(db.String(240)) date = db.Column(db.String(240)) def __repr__(self): return '<Message %r>' % (self.user)
class LinkData(db.Model): id = db.Column(db.Integer, primary_key=True) username = db.Column(db.String(64)) firstname = db.Column(db.String(64)) user_id = db.Column(db.Integer) chat_id = db.Column(db.Integer) text = db.Column(db.Text, nullable=True) def __repr__(self): return '<User %r>' % (self.username)
class Message(db.Model): __tablename__ = "message" id = db.Column(db.Integer, primary_key=True) #id nickname = db.Column(db.String(32)) #昵称 qq = db.Column(db.String(32)) #qq email = db.Column(db.String(64)) #邮箱 time = db.Column(db.DATETIME) #时间 description = db.Column(db.TEXT) #留言内容 def __repr__(self): return self.nickname
class CMSUser(db.Model): __tablename__ = "cms_user" # db.Column表示是数据库真实存在的字段, primary_key表示为主键, autoincrement表示自动增长, 每次加1 # Integer是整形 id = db.Column(db.Integer, primary_key=True, autoincrement=True) # String字符串 长度50个字符 # nullable 如果为True,允许有空值,如果为False,不允许有空值 username = db.Column(db.String(50), nullable=False) _password = db.Column(db.String(100), nullable=False) # unique 如果为True,代表这列不允许出现重复的值 email = db.Column(db.String(50), nullable=False, unique=True) join_time = db.Column(db.DateTime, default=datetime.now)
class ClassRoom(db.Model): """ 课室的数据库模型类 """ __tablename__ = "login_classroom" id = db.Column(db.Integer, primary_key=True) class_number = db.Column(db.String(10), nullable=False) block_number = db.Column(db.Integer) ip_addr = db.Column(db.String(80), nullable=False) ACL = db.Column(db.String(20), nullable=False)
class Filelist(db.Model): __tablename__ = "filelist" id = db.Column(db.Integer, primary_key=True) #id filename = db.Column(db.String(32)) #文件名称 type = db.Column(db.String(32)) #文件类型 filesize = db.Column(db.String(32)) #文件大小 filepath = db.Column(db.String(64)) #文件存放路径 # time = db.Column(db.DATETIME) #时间 time = db.Column(db.TEXT) #文件上传时间 description = db.Column(db.TEXT) #文件介绍 def __repr__(self): return self.filename
class Article(db.Model): __tablename__ = "article" id = db.Column(db.Integer, primary_key=True) title = db.Column(db.String(32)) author = db.Column(db.String(32)) picture = db.Column(db.String(32)) time = db.Column(db.DATETIME) types = db.Column(db.String(32)) content = db.Column(db.TEXT) description = db.Column(db.TEXT) def __repr__(self): return self.title