class Laboratory(Model): __tablename__ = 'laboratory' id = Column(Integer, primary_key=True) name = Column(String()) created_at = Column(DateTime(), default=func.now()) updated_at = Column(DateTime(), onupdate=datetime.datetime.now) sub_samples = relationship('SubSample', cascade='all,delete-orphan', backref='laboratory') def __repr__(self): return '<id {}>'.format(self.id)
class SubSample(Model): __tablename__ = 'sub_sample' id = Column(Integer, primary_key=True) sample_id = Column(Integer, ForeignKey('sample.id'), nullable=False) identified_by = Column(Integer, ForeignKey('scientist.id')) identified_by_lab = Column(Integer, ForeignKey('laboratory.id')) individual_count = Column(Integer) specimen_id = Column(Integer, ForeignKey('specimen.id')) created_at = Column(DateTime(), default=func.now()) updated_at = Column(DateTime(), onupdate=datetime.datetime.now) def __repr__(self): return '<id {}>'.format(self.id)
class Sample(Model): __tablename__ = 'sample' id = Column(Integer, primary_key=True) set_date = Column(DateTime()) collect_date = Column(DateTime()) location_id = Column(Integer, ForeignKey('location.id')) sub_samples = relationship('SubSample', cascade='all,delete-orphan', backref='sample') created_at = Column(DateTime(), default=func.now()) updated_at = Column(DateTime(), onupdate=datetime.datetime.now) def __repr__(self): return '<id {}>'.format(self.id)
class Location(Model): __tablename__ = 'location' id = Column(Integer, primary_key=True) site_id = Column(String()) domain = Column(String()) named_location = Column(String(), unique=True) elevation = Column(Float) point = Column(Geometry('POINT', srid=4326)) nlcd_class_id = Column(ForeignKey('nlcd_class.id')) county = Column(String()) state = Column(String()) country = Column(String()) created_at = Column(DateTime(), default=func.now()) updated_at = Column(DateTime(), onupdate=datetime.datetime.now) samples = relationship('Sample', cascade='all,delete-orphan', backref='location') def __repr__(self): return '<id {}>'.format(self.id)
class Specimen(Model): __tablename__ = 'specimen' id = Column(Integer, primary_key=True) kingdom = Column(String()) phylum = Column(String()) # class is a reserved keyword tax_class = Column('class', String()) order = Column(String()) family = Column(String()) subfamily = Column(String()) tribe = Column(String()) genus = Column(String()) subgenus = Column(String()) species = Column(String()) sub_samples = relationship('SubSample', cascade='all,delete-orphan', backref='specimen') created_at = Column(DateTime(), default=func.now()) updated_at = Column(DateTime(), onupdate=datetime.datetime.now) def __repr__(self): return '<id {}>'.format(self.id)