class Product(db.Model): __tablename__ = "product" pid = db.Column(db.Integer, primary_key=True) name = db.Column(db.String(100), unique=True, nullable=False) cost = db.Column(db.Float, nullable=False) details = db.Column(db.String(500), nullable=False) category_id = db.Column(db.Integer, db.ForeignKey(Category.__table__.c.cid), nullable=False) sid = db.Column(db.Integer, db.ForeignKey(Seller.__table__.c.sid), nullable=False) image_file1 = db.Column(db.String(20), nullable=False, default='default.jpg') image_file2 = db.Column(db.String(20), nullable=False, default='default.jpg') image_file3 = db.Column(db.String(20), nullable=False, default='default.jpg') image_file4 = db.Column(db.String(20), nullable=False, default='default.jpg') stock = db.Column(db.Integer, nullable=False)
class Order(db.Model): __tablename__="order" oid = db.Column(db.Integer, primary_key=True) uid = db.Column(db.Integer, db.ForeignKey(User.__table__.c.id), nullable=False) pid = db.Column(db.Integer, db.ForeignKey(Product.__table__.c.pid), nullable=False) quantity = db.Column(db.Integer, nullable=False) total = db.Column(db.Integer, nullable=False) order_date = db.Column(db.DateTime, nullable=False, default=datetime.utcnow) order_status = db.Column(db.String, nullable=False)
class Cart(db.Model): __tablename__ = "cart" uid = db.Column(db.Integer, db.ForeignKey(User.__table__.c.id), primary_key=True) pid = db.Column(db.Integer, db.ForeignKey(Product.__table__.c.pid), primary_key=True) quantity = db.Column(db.Integer, nullable=False)
class Review(db.Model): __tablename__="review" user_id = db.Column(db.Integer, db.ForeignKey(User.__table__.c.id), primary_key=True, nullable=False) prod_id = db.Column(db.Integer, db.ForeignKey(Product.__table__.c.pid), primary_key=True, nullable=False) date_posted = db.Column(db.DateTime, nullable=False, default=datetime.utcnow) content = db.Column(db.String(300), nullable=False) user_name = db.Column(db.String(75)) def __repr__(self): return f"Review('{self.user_id}', '{self.prod_id}')"
class Shipping(db.Model): __tablename__ = "shipping" ship_id = db.Column(db.Integer, primary_key=True) oid = db.Column(db.Integer, db.ForeignKey(Order.__table__.c.oid), nullable=False) transac_id = db.Column(db.Integer, db.ForeignKey(UserTransac.__table__.c.transac_id), nullable=False) tracking_no = db.Column(db.Numeric(12, 0), unique=True, nullable=False) delivery_date = db.Column(db.DateTime, nullable=False, default=datetime.utcnow) details = db.Column(db.String(100))
class UserTransac(db.Model): __tablename__ = "usertransac" transac_id = db.Column(db.Integer, primary_key=True) uid = db.Column(db.Integer, db.ForeignKey(User.__table__.c.id), nullable=False) oid = db.Column(db.Integer, db.ForeignKey(Order.__table__.c.oid), nullable=False) upiid = db.Column(db.String(120), unique=True, nullable=False) upipin = db.Column(db.Integer, unique=True, nullable=False) transac_date = db.Column(db.DateTime, nullable=False, default=datetime.utcnow) transac_details = db.Column(db.String(100))
class Shipping(db.Model): __tablename__="shipping" ship_id = db.Column(db.Integer, primary_key=True) oid = db.Column(db.Integer, db.ForeignKey(Order.__table__.c.oid), nullable=False) delivery_date = db.Column(db.DateTime, nullable=False, default=datetime.utcnow) details = db.Column(db.String(100)) contactno = db.Column(db.Integer, unique=True, nullable=False) address_line1 = db.Column(db.String(50), nullable=False) address_line2 = db.Column(db.String(50)) address_line3 = db.Column(db.String(50)) pincode = db.Column(db.Integer, nullable=False) city = db.Column(db.String(50), nullable=False) state = db.Column(db.String(50), nullable=False) country = db.Column(db.String(50), nullable=False)