本文整理汇总了Python中models.Employee方法的典型用法代码示例。如果您正苦于以下问题:Python models.Employee方法的具体用法?Python models.Employee怎么用?Python models.Employee使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类models
的用法示例。
在下文中一共展示了models.Employee方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: init_db
# 需要导入模块: import models [as 别名]
# 或者: from models import Employee [as 别名]
def init_db():
# import all modules here that might define models so that
# they will be registered properly on the metadata. Otherwise
# you will have to import them first before calling init_db()
from models import Department, Employee, Role
for model in [Department, Employee, Role]:
if model.exists():
model.delete_table()
model.create_table(read_capacity_units=1, write_capacity_units=1, wait=True)
# Create the fixtures
engineering = Department(id=str(uuid4()), name='Engineering')
engineering.save()
hr = Department(id=str(uuid4()), name='Human Resources')
hr.save()
manager = Role(id=str(uuid4()), name='manager')
manager.save()
engineer = Role(id=str(uuid4()), name='engineer')
engineer.save()
peter = Employee(id=str(uuid4()), name='Peter', department=engineering, role=engineer)
peter.save()
roy = Employee(id=str(uuid4()), name='Roy', department=engineering, role=engineer)
roy.save()
tracy = Employee(id=str(uuid4()), name='Tracy', department=hr, role=manager)
tracy.save()
示例2: init_db
# 需要导入模块: import models [as 别名]
# 或者: from models import Employee [as 别名]
def init_db():
# import all modules here that might define models so that
# they will be registered properly on the metadata. Otherwise
# you will have to import them first before calling init_db()
from models import Department, Employee, Role
Base.metadata.drop_all(bind=engine)
Base.metadata.create_all(bind=engine)
# Create the fixtures
engineering = Department(name='Engineering')
db_session.add(engineering)
hr = Department(name='Human Resources')
db_session.add(hr)
manager = Role(name='manager')
db_session.add(manager)
engineer = Role(name='engineer')
db_session.add(engineer)
peter = Employee(name='Peter', department=engineering, role=engineer)
db_session.add(peter)
roy = Employee(name='Roy', department=engineering, role=engineer)
db_session.add(roy)
tracy = Employee(name='Tracy', department=hr, role=manager)
db_session.add(tracy)
db_session.commit()
示例3: init_db
# 需要导入模块: import models [as 别名]
# 或者: from models import Employee [as 别名]
def init_db():
# Create the fixtures
engineering = Department(name="Engineering")
engineering.save()
hr = Department(name="Human Resources")
hr.save()
manager = Role(name="manager")
manager.save()
engineer = Role(name="engineer")
engineer.save()
debug = Task(name="Debug")
test = Task(name="Test")
tracy = Employee(name="Tracy", department=hr, roles=[engineer, manager], tasks=[])
tracy.save()
peter = Employee(
name="Peter",
department=engineering,
leader=tracy,
roles=[engineer],
tasks=[debug, test],
)
peter.save()
roy = Employee(
name="Roy",
department=engineering,
leader=tracy,
roles=[engineer],
tasks=[debug],
)
roy.save()