mirror of
https://github.com/mariadb-corporation/dev-example-blog-samples.git
synced 2025-08-13 13:12:49 +00:00
21 lines
777 B
Python
21 lines
777 B
Python
from sqlalchemy import Column, String, Integer, Boolean, ForeignKey
|
|
from sqlalchemy.orm import relationship, backref
|
|
|
|
from base import Base
|
|
|
|
class Employee(Base):
|
|
__tablename__ = 'employees'
|
|
|
|
id = Column(Integer, primary_key=True)
|
|
department_id = Column(Integer, ForeignKey('departments.id'))
|
|
firstname = Column(String(length=100))
|
|
lastname = Column(String(length=100))
|
|
active = Column(Boolean, default=True)
|
|
department = relationship("Department", back_populates="employees")
|
|
|
|
#contact_details = relationship("ContactDetails", backref=backref("contact_details", uselist=False))
|
|
|
|
def __init__(self, firstname, lastname, department):
|
|
self.firstname = firstname
|
|
self.lastname = lastname
|
|
self.department = department |