Пример #1
0
class Loja(db.Model):
    id = db.Column(db.Integer, primary_key=True)
    titulo = db.Column(db.String(20))
    funcs = db.relationship('Funcionario', backref='loja', lazy='dynamic')

    def __init__(self, t):
        self.titulo = t
Пример #2
0
class Funcionario(db.Model):
    id = db.Column(db.Integer, primary_key=True)

    id_loja = db.Column(db.Integer, db.ForeignKey('loja.id'))
Пример #3
0
class Disciplina(db.Model):
    id = db.Column(db.Integer, primary_key=True)
    alunos = db.relationship('Aluno',
                             secondary=matriculas,
                             backref=db.backref('disciplina', lazy='dynamic'))
Пример #4
0
class Telefone(db.Model):
    id = db.Column(db.Integer, primary_key=True)
Пример #5
0
class Pessoa(db.Model):
    id = db.Column(db.Integer, primary_key=True)

    id_telefone = db.Column(db.Integer, db.ForeignKey('telefone.id'))

    telefone = db.relationship('Telefone', backref='pessoa', uselist=False)
Пример #6
0

class Pessoa(db.Model):
    id = db.Column(db.Integer, primary_key=True)

    id_telefone = db.Column(db.Integer, db.ForeignKey('telefone.id'))

    telefone = db.relationship('Telefone', backref='pessoa', uselist=False)


class Telefone(db.Model):
    id = db.Column(db.Integer, primary_key=True)


matriculas = db.Table(
    'matriculas', db.Column('aluno_id', db.Integer, db.ForeignKey('aluno.id')),
    db.Column('disciplina_id', db.Integer, db.ForeignKey('disciplina.id')))


class Aluno(db.Model):
    id = db.Column(db.Integer, primary_key=True)

    disciplinas = db.relationship('Disciplina',
                                  secondary=matriculas,
                                  backref=db.backref('aluno', lazy='dynamic'))


class Disciplina(db.Model):
    id = db.Column(db.Integer, primary_key=True)
    alunos = db.relationship('Aluno',
                             secondary=matriculas,