import flask_sqlalchemy db = flask_sqlalchemy.SQLAlchemy(session_options=dict(autoflush=False)) class Product(db.Model): __tablename__ = 'products' id = db.Column(db.Integer, primary_key=True) name = db.Column(db.String) product_name = db.Column(db.String) price = db.Column(db.String) time_left = db.Column(db.String) days_left = db.Column(db.Integer) url = db.Column(db.String) image_url = db.Column(db.String) variants = db.relationship('Variant', backref='product') class Variant(db.Model): __tablename__ = 'variants' id = db.Column(db.Integer, primary_key=True) product_id = db.Column(db.Integer, db.ForeignKey('products.id'), primary_key=True) color = db.Column(db.String) front_url = db.Column(db.String) back_url = db.Column(db.String)