Exemple #1
0
def db(app):
    _db.app = app

    with app.app_context():
        _db.create_all()

    yield _db

    _db.session.close()
    _db.drop_all()
Exemple #2
0
def init():
    """Initialize application

    Initializes the SQLAlchemy [flasksqla]_ database and adds a default user.
    """

    from smoke_backend.extensions import db

    click.echo("create database")
    db.create_all()
    click.echo("done")
Exemple #3
0
def init():
    """Init application, create database tables
    and create a new user named admin with password admin
    """
    from smoke_backend.extensions import db
    from smoke_backend.models import User
    click.echo("create database")
    db.create_all()
    click.echo("done")

    click.echo("create user")
    user = User(username='******',
                email='*****@*****.**',
                password='******',
                active=True)
    db.session.add(user)
    db.session.commit()
    click.echo("created user admin")
Exemple #4
0
def init():
    """Init application, create database tables
    and create a new user named admin with password admin
    """
    '''' Import the database of User objects through SQLAlchemy '''
    from smoke_backend.extensions import db
    ''' Import the User class '''
    from smoke_backend.models import User
    ''' Form the database tables '''
    click.echo("create database")
    db.create_all()
    click.echo("done")
    ''' Create the default user '''
    click.echo("create user")
    user = User(username='******',
                email='*****@*****.**',
                password='******',
                active=True)
    ''' Add the user to the database '''
    db.session.add(user)
    db.session.commit()
    click.echo("created user admin")