def add_user(id_: int, paraphrase: str, session: Session) -> None: """Add new users to the database.""" if session.query(exists().where(User.id == id_)).scalar(): raise UserExists(id_=id_) else: new_user = User(id=id_, paraphrase=sha224(paraphrase.encode('utf-8')).hexdigest()) session.add(new_user) session.commit()
def add_user(id_, paraphrase, session): """Add new users to the database.""" if session.query(exists().where(User.id == id_)).scalar(): raise UserExists(id_=id_) else: new_user = User(id=id_, paraphrase=paraphrase) session.add(new_user) session.commit()