Exemplo n.º 1
0
class class_m2m_lesson(Base):
    '''班级与课程对应关系表'''
    __tablename__ = 'class_m2m_course'
    id = Column(Integer, primary_key=True, autoincrement=1)
    class_id = (Integer, ForeignKey('class.id'))
    lesson_id = (Integer, ForeignKey('lesson.id'))
    classes = relationships('Class', backref='class_m2m_lesson')
    lessons = relationships('Lesson', backref='class_m2m_lesson')

    def __repr__(self):
        return self.id, self.class_id, self.lesson_id
Exemplo n.º 2
0
class StudyRecord(Base):
    '''上课记录表'''
    __tablename__ = 'study_record'
    id = Column(Integer, primary_key=True, autoincrement=1)
    student_id = Column(Integer, ForeignKey('student.id'))
    class_m2m_lesson_id = Column(Integer, ForeignKey('class_m2m_lesson.id'))
    status = Column(String(16))
    score = Column(Integer)

    class_id_lessons = relationships('Class_m2m_lesson',
                                     backref='my_study_record')
    student = relationships('Studeng', backref='my_study_record')

    def __repr__(self):
        return self.class_m2m_lessons, self.student, self.status, self.score
Exemplo n.º 3
0
class Employee(Base):
    __tablename__ = 'employees'
    employee_id = Column(Integer, primary_key=True)
    name = Column(String)
    hired_on = Column(DateTime, default=func.now())
    department_id = Column(Integer, ForeignKey('department.id'))
    role_id = Column(Integer, ForeignKey('roles.role_id'))
    department = relationships(Department,
                               backref=backref('employee',
                                               uselist=True,
                                               cascade='delete,all'))
    role = relationships(Role,
                         backref=backref('roles',
                                         uselist=True,
                                         cascade='delete,all'))
Exemplo n.º 4
0
class User(Base):
    __tablename__ = 'user'

    id = Column(String(20), primary_key=True)
    name = Column(String(20))
    # 一对多:
    books = relationships('Book')
Exemplo n.º 5
0
Arquivo: gift.py Projeto: lhyyp/fisher
class Gift(Base):
    id = Column(Integer, primary_key=True, autoincrement=True)
    user = relationships("User")
    uid = Column(Integer, ForeignKey("user.id"))
    isbn = Column(String(30), nullable=False)
    # book = relationships("Book")
    # bid = Column(Integer, ForeignKey("book.id"))
    launched = Column(Boolean, default=False)
Exemplo n.º 6
0
class Gift(Base):
    id = Column(Integer, primary_key=True, autoincrement=True)
    user = relationships('User')
    uid = Column(Integer, ForeignKey('user.id'))
    isbn = Column(String(20), nullable=False)
    # book = relationships('Book')
    # bid = Column(Integer, ForeignKey('book.id'))
    launched = Column(Boolean, default=False)
Exemplo n.º 7
0
class ClassInfo(Base):
    __tablename__ = 'classes'
    id = Column(Integer, primary_key=True)
    class_name = Column(String[32])
    teacher_name = Column(String[32])
    courses = relationships("CourseInfo", backref="class_info")

    def __ref__(self):
        return '<Class %r>' % self.teacher_name
Exemplo n.º 8
0
class Gift(Base):
    id = Column(Integer, primary_key=True)
    user = relationships('User')
    uid = Column(Integer, ForeignKey('user.id'))
    launched = Column(Boolean, nullable=False)
    isbn = Column(String(15), nullable=False)
    # book = relationships('Book')
    # bid = Column(Integer, ForeignKey('book.id'))
    status = Column(SmallInteger, default=0)
Exemplo n.º 9
0
class Mod(Base):
    __tablename__ = 'mod'

    id = Column(Integer, primary_key=True)
    name = Column(String)
    gameId = Column(Integer)
    summary = Column(Text)

    authors = relationships("User", backref="mod", order_by="User.id")
Exemplo n.º 10
0
class MenuItems(Base):
    __tablename__ = 'menu_items'

    id = Column(Integer, primary_key=True)
    name = Column(String(80), nullable=False)
    description = Column(String(250))
    price = Column(String(8))
    course = Column(String(250))
    restaurant_id = Column(Integer, ForeignKey('restaurant.id'))
    restaurant = relationships(Restaurant)
Exemplo n.º 11
0
class Teacher(Base):
    '''讲师表'''
    __tablename__ = 'teacher'
    id = Column(Integer, primary_key=True, autoincrement=1)
    teacher_name = Column(String(64))
    class_name = relationships('Class',
                               secondary=teacher_m2m_class,
                               backref='teacher')

    def __repr__(self):
        return self.teacher_name
Exemplo n.º 12
0
class Student(Base):
    __tablename__ = 'students'
    id = Column(Integer, primary_key=True)
    name = Column(String(32))

    courses = relationship("CourseInfo",
                           secondary=student_course_table,
                           backref="students")
    mobiles = relationships("Mobile", backref="student")

    def __repr__(self):
        return '<Student %r>' % self.name
class Tweet(Base):
    __tablename__ = 'tweets'
    id = Column(Integer, primary_key=True)
    tid = Column(String(100, nullable=False))
    tweet = Column(String(300), nullable=False)
    user_id = Column(Integer, ForeignKey)
    coordinates =
    user =
    created_at =
    favourite_count =
    in_reply_to_screen_name = Column(String)
    in_reply_to_status_id = Column(Integer)
    in_reply_to_user_id = Column(Integer)
    lang = Column(String)
    quoted_status_id = Column(Integer)
    retweet_count = Column(Integer)
    source = Column(String)
    is_retweet = Column(Boolean)
    hashtags = relationships('Hashtag',
                             secondary = 'hashtag_tweet',
                             back_populates = 'tweets')

    def __repr__(self):
        return '<Tweet {}>'.format(self.id)
Exemplo n.º 14
0
class Gift(Base):
    id = Column(Integer, primary_key=True)
    user = relationships('User')
    uid = Column(Integer, ForeignKey('user.id'))
    isbn = isbn = Column(String(15), nullable=False)
    launched = Column(Boolean, default=False)

    @property
    def book(self):
        yushu_book = YuShuBook()
        yushu_book.search_by_isbn(self.isbn)
        return yushu_book.first

    @classmethod
    def recent(cls):
        # 链式调用
        # 主体
        # 子函数
        recent_gift = Gift.query.filter_by(
            launched=False).group_by(
            Gift.isbn).order_by(
            Gift.create_datetime).limit(
            current_app.config['RECENT_BOOKCOUNT']).distinct().all()
        return recent_gift