Пример #1
0
class Name(db.Model):
    __tablename__ = 'name'
    id = db.Column(db.Integer, autoincrement=True, primary_key=True)
    name = db.Column(db.String)
    persons = db.relationship('Person', backref='carrier')

    def __init__(self, name):
        self.name = name
Пример #2
0
class Book(db.Model):
    __tablename__ = 'book'
    id = db.Column(db.Integer, autoincrement=True, primary_key=True)
    name = db.Column(db.String)
    author_id = db.Column(db.Integer, db.ForeignKey('author.id'))
    genre_id = db.Column(db.Integer, db.ForeignKey('genre.id'))
    characters = db.relationship('Character', secondary=books_char_relation, backref=db.backref('characters'),
                                 lazy='dynamic')
Пример #3
0
class IdCard(db.Model):
    __tablename__ = 'id_card'
    id = db.Column(db.Integer, autoincrement=True, primary_key=True)
    count_of_books = db.Column(db.Integer)
    user_id = db.Column(db.Integer, db.ForeignKey('user_table.id'))
    user = db.relationship('User', backref=db.backref('user'))
Пример #4
0
class Genre(db.Model):
    __tablename__ = 'genre'
    id = db.Column(db.Integer, autoincrement=True, primary_key=True)
    name = db.Column(db.String)
    books = db.relationship('Book', backref='genre')
Пример #5
0
class Author(db.Model):
    __tablename__ = 'author'
    id = db.Column(db.Integer, autoincrement=True, primary_key=True)
    name = db.Column(db.String)
    books = db.relationship('Book', backref='author')
    city = db.Column(db.String)
Пример #6
0
class User(db.Model):
    __tablename__ = 'user_table'
    id = db.Column(db.Integer, autoincrement=True, primary_key=True)
    name = db.Column(db.String)
    books = db.relationship('Book', secondary=user_books_relation, backref=db.backref('users'), lazy='dynamic')