INNER CODE UNIT · Python

create_user

rochacbruno/fastapi-project-template · project_name/cli.py:32

def create_user(username: str, password: str, superuser: bool = False):
    """Create user"""
    create_db_and_tables(engine)
    with Session(engine) as session:
        user = User(username=username, password=password, superuser=superuser)
        session.add(user)
        session.commit()
        session.refresh(user)
        typer.echo(f"created {username} user")
        return user


@cli.command()
def shell():  # pragma: no cover
    """Opens an interactive shell with objects auto imported"""
    _vars = {
        "app": app,
        "settings": settings,

View source record →

📰 Research Paper
Loading…
⏳ Fetching content…