class Student(db.Model): __tablename__ = "students" id = db.Column(db.Integer, primary_key=True, autoincrement=True) name = db.Column(db.String(20), nullable=False) score = db.Column(db.Float, nullable=False) school_id = db.Column(db.Integer, db.ForeignKey("schools.id"), nullable=False)
class Student(db.Model): # 学生模型 __tablename__ = "students" id = db.Column(db.Integer, primary_key=True, autoincrement=True) name = db.Column(db.String(20), nullable=False) score = db.Column(db.Float, nullable=False)
class User(db.Model): __tablename__ = "users" id = db.Column(db.Integer, primary_key=True, autoincrement=True) username = db.Column(db.String(20), nullable=False) password = db.Column(db.String(20), nullable=False)
class Fruit(db.Model): __tablename__ = "fruits" id = db.Column(db.Integer, primary_key=True, autoincrement=True) name = db.Column(db.String(20), nullable=False) price = db.Column(db.Float, nullable=False)
class School(db.Model): __tablename__ = "schools" id = db.Column(db.Integer, primary_key=True, autoincrement=True) name = db.Column(db.String(20), nullable=False) address = db.Column(db.String(50), nullable=False) students = db.relationship("Student", backref="sch")