コード例 #1
0
 def get_department_by_id(self, id):
     return Department.from_tuple(
         self.cursor.execute(
             """
         SELECT *
         FROM departments
         WHERE id = ?
     """, (id, )).fetchone())
コード例 #2
0
def new_department():
    new_department_data = Department.from_tuple(
        tuple([0] + request.data.decode("utf-8").split(",")))
    error = context.repository.add_department(
        new_department_data.name, new_department_data.country,
        new_department_data.city, new_department_data.address,
        new_department_data.department_manager)
    if error == "DEPARTMENT NAME DUPLICATE":
        return "This department name is occupied", 400
    context.repository.commit()
    return "", 204