from app import db from marshmallow import Schema, fields, ValidationError, pre_load authors = db.Table('books_authors', db.Column('book_id', db.Integer, db.ForeignKey('books.id'), primary_key=True), db.Column('author_id', db.Integer, db.ForeignKey('authors.id'), primary_key=True) ) stacks = db.Table('books_stacks', db.Column('book_id', db.Integer, db.ForeignKey('books.id'), primary_key=True), db.Column('stack_id', db.Integer, db.ForeignKey('stacks.id'), primary_key=True) ) class Book(db.Model): __tablename__ = 'books' id = db.Column(db.Integer, primary_key = True) title = db.Column(db.String(255)) file = db.Column(db.String(255)) cover = db.Column(db.String(255)) fileformat = db.Column(db.String(255)) category = db.Column(db.String(255)) authors = db.relationship('Author', secondary=authors,cascade="delete", lazy='subquery', backref=db.backref('books', lazy=True),passive_deletes=True) stacks = db.relationship('Stack', secondary=stacks, lazy='subquery', backref=db.backref('books', lazy=True)) scapeX = db.Column(db.Numeric(10,2)) scapeY = db.Column(db.Numeric(10,2)) def __init__(self, title, file, cover, fileformat, category): self.title = title self.file = file self.cover = cover self.fileformat = fileformat self.category = category self.scapeX = 0 self.scapeY = 0 def __repr__(self): return '