from sqlalchemy import Column, Integer, String, Table from sqlalchemy.orm import relationship from sqlalchemy import ForeignKey from ._base import Base from ._customer import Customer from ._group import Group from ._job import Job customer_group = Table('customer_group', Base.metadata, Column('customer_id', Integer, ForeignKey('customers.id')), Column('group_id', Integer, ForeignKey('groups.id')) ) Customer.groups = relationship("Group", secondary=customer_group, back_populates="members") Group.members = relationship("Customer", secondary=customer_group, back_populates="groups") customer_job = Table('customer_job', Base.metadata, Column('customer_id', Integer, ForeignKey('customers.id')), Column('job_id', Integer, ForeignKey('jobs.id')) ) Customer.jobs = relationship("Job", secondary=customer_job, back_populates="customers") Job.customers = relationship("Customer", secondary=customer_job, back_populates="jobs")