def find_worker_by_name(session: Session, name: str) -> models.Worker: try: worker = session.query(models.Worker).filter_by(name=name).one() except NoResultFound: worker = models.Worker() worker.name = name session.add(worker) session.commit() return worker
def create_worker(self, worker_values): values = copy.deepcopy(worker_values) values['id2'] = uuidutils.generate_uuid() worker = models.Worker() params = worker.generate_param() for k, v in params.items(): params[k] = values.get(k) worker.update(params) self.add(worker) return self.get_worker_by_id2(values['id2'])
def create_worker(db: Session, worker: schemas.WorkerCreate): db_worker = models.Worker(first_name=worker.first_name, last_name=worker.last_name, email=worker.email, address=worker.address, password=worker.password, phone_number=worker.phone_number) db.add(db_worker) db.commit() db.refresh(db_worker) return db_worker
def add_worker(): email = request.json['email'] name = request.json['name'] phone_number = request.json['phone_number'] experiences = request.json['experiences'] skills = request.json['skills'] location = request.json['location'] profile_img = request.json['profile_img'] bio = request.json['bio'] links = request.json['links'] certifications = request.json['certifications'] new_worker = models.Worker(name, email,phone_number, experiences,skills,location,profile_img,bio,links,certifications) db.session.add(new_worker) db.session.commit() return "201 Created Worker"
def create_worker(db: Session, worker: schemas.WorkerBase): db_user = models.Worker(name=worker.name) db.add(db_user) db.commit() db.refresh(db_user) return db_user