コード例 #1
0
def init_db():
    db.create_all()
    click.echo('Initialized database.')
    admin = User(
        username='******',
        email='*****@*****.**',
    )
    admin.set_password('admin')
    db.session.add(admin)
    db.session.commit()
    click.echo('Success Add Admin Count.')
コード例 #2
0
 def initdb(drop):
     """Initialize the database."""
     if drop:
         click.confirm(
             'This operation will delete the database, do you want to continue?',
             abort=True)
         db.drop_all()
         click.echo('Drop tables.')
     db.create_all()
     user = User(
         username='******',
         email='*****@*****.**',
     )
     user.set_password('admin')
     db.session.add(user)
     db.session.commit()
     click.echo('Initialized database...Success Add admin count.')
コード例 #3
0
def reset_db():
    """Initialize the database."""

    click.confirm(
        'This operation will delete the database, do you want to continue?',
        abort=True)
    db.drop_all()
    click.echo('Drop tables.')
    db.create_all()
    click.echo('Initialized database.')
    admin = User(
        username='******',
        email='*****@*****.**',
    )
    admin.set_password('admin')
    db.session.add(admin)
    db.session.commit()
    click.echo('Success Add Admin Count.')
コード例 #4
0
def set_user(username, email, password):
    """Add A New User."""

    click.echo('Initializing the database...')
    db.create_all()

    user = User.query.first()
    if user is not None:
        click.echo('The useristrator already exists, updating...')
        user.username = username
        user.email = email
        user.set_password(password)
    else:
        click.echo('Creating the temporary useristrator account...')
        user = User(
            username=username,
            email=email,
        )
        user.set_password(password)
        db.session.add(user)
        db.session.commit()