Skip to content

Instantly share code, notes, and snippets.

@UltraBob
Created June 22, 2016 12:18
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save UltraBob/c74f75c0e36427856ab78f530fc89d4c to your computer and use it in GitHub Desktop.
Save UltraBob/c74f75c0e36427856ab78f530fc89d4c to your computer and use it in GitHub Desktop.
company_technologies = db.Table('company_technologies',
db.Column('company_id', db.Integer, db.ForeignKey('companies.id')),
db.Column('technology_id', db.Integer, db.ForeignKey('technologies.id'))
)
class Technology(db.Model):
__tablename__ = 'technologies'
id = db.Column(db.Integer, primary_key=True)
name = db.Column(db.String(128), index=True)
parent_id = db.Column(db.Integer, default=None, nullable=True, index=True)
class Company(db.Model):
__tablename__ = 'companies'
id = db.Column(db.Integer, primary_key=True)
name = db.Column(db.String(128), unique=True, index=True)
technologies = db.relationship('Technology',
secondary=company_technologies,
backref=db.backref('technologies', lazy='dynamic'),
lazy='dynamic')
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment