class User(db.Model): user_id = db.Column(db.Integer, primary_key=True) username = db.Column(db.String(16), nullable=False) password = db.Column(db.String(16), nullable=False) email = db.Column(db.String(16), nullable=False) def save(self): # 添加数据 db.session.add(self) db.session.commit()
class Article(db.Model): aid = db.Column(db.Integer, primary_key=True, autoincrement=True) title = db.Column(db.String(100), nullable=True) content = db.Column(db.String(10000)) create_time = db.Column(db.DateTime, default=datetime.now) cid = db.Column(db.Integer, db.ForeignKey("category.cid", ondelete="CASCADE")) hits = db.Column(db.Integer, default=0) comments = db.Column(db.Integer, default=0) picture = db.Column(db.String(300)) __tablename__ = 'article'
class commodity_base_info(db.Model): id = db.Column(db.Integer, primary_key=True, autoincrement=True) commodity_type = db.Column(db.String(30), nullable=False) commodity_name = db.Column(db.String(30), nullable=False) commodity_brand = db.Column(db.String(30), nullable=False) commodity_base_price = db.Column(db.String(30), nullable=False) img_path = db.Column(db.String(30), nullable=False) info = db.Column(db.String, nullable=False) def save(self): db.session.add(self) db.session.commit()
class User(db.Model, UserMixin): uid = db.Column(db.Integer, primary_key=True, autoincrement=True) username = db.Column(db.String(30), nullable=False) password = db.Column(db.String(128), nullable=False) sex = db.Column(db.Boolean, default=False, name='gender') # replies = db.relationship('Article', backref='user', lazy="dynamic") # detail = db.relationship("UserDetail", backref='user', lazy='dynamic', uselist=False) __tablename__ = 'User' __table_args__ = {'extend_existing': True} def get_id(self): try: return text_type(self.uid) except AttributeError: raise NotImplementedError('No `id` attribute - override `get_id`')
class commodity_review_info(db.Model): id = db.Column(db.Integer, primary_key=True, autoincrement=True) commodity_type = db.Column(db.String(30), nullable=False) commodity_name = db.Column(db.String(30), nullable=False) commodity_brand = db.Column(db.String(30), nullable=False) review_url = db.Column(db.String(30), nullable=False) review_title = db.Column(db.String, nullable=False) review_img_path = db.Column(db.String, nullable=False) review_excerpt = db.Column(db.String, nullable=False) # zhihu_x_zse_86 = db.Column(db.String, nullable=False) def save(self): db.session.add(self) db.session.commit()
class commodity_history_price(db.Model): id = db.Column(db.Integer, primary_key=True, autoincrement=True) commodity_price_id = db.Column(db.Integer, nullable=True) insert_time = db.Column(db.DATETIME, nullable=True) price = db.Column(db.String(30), nullable=False) def save(self): db.session.add(self) db.session.commit() def save_all(self, price_list): price = [] for i in price_list: price.append( commodity_history_price(commodity_price_id=i[0], price=i[1], insert_time=i[2])) db.session.add_all(price) db.session.commit()
class User(db.Model, UserMixin): uid = db.Column(db.Integer, primary_key=True, autoincrement=True) username = db.Column(db.String(30), nullable=False, unique=True) password = db.Column(db.String(128), nullable=False) phone = db.Column(db.String(11)) email = db.Column(db.String(200)) portrait = db.Column(db.String(300)) regtime = db.Column(db.DateTime) isforbid = db.Column(db.Boolean, default=False) img = db.Column(db.String(255)) __tablename__ = 'user' __table_args__ = {'extend_existing': True} def get_id(self): try: return text_type(self.uid) except AttributeError: raise NotImplementedError('No `id` attribute - override `get_id`')
class Cat(db.Model): id = db.Column(db.Integer, primary_key=True, autoincrement=True) name = db.Column(db.String(32))
class Student(db.Model): id = db.Column(db.Integer, primary_key=True) name = db.Column(db.String(16))
class Category(db.Model): cid = db.Column(db.Integer, primary_key=True, autoincrement=True) name = db.Column(db.String(100), nullable=False, unique=True) num = db.Column(db.Integer, default=0) __tablename__ = "category"
class Tag(db.Model): tid = db.Column(db.Integer, primary_key=True, autoincrement=True) name = db.Column(db.String(30), nullable=True) aid = db.Column(db.Integer, db.ForeignKey("article.aid"))
class Mark(db.Model): mid = db.Column(db.Integer, primary_key=True, autoincrement=True) content = db.Column(db.String(1000)) create_time = db.Column(db.DateTime) uid = db.Column(db.Integer, db.ForeignKey('user.uid')) aid = db.Column(db.Integer)