def db(base_app):
    """Initialize database."""
    # Init
    if not database_exists(str(_db.engine.url)):
        create_database(str(_db.engine.url))
    _db.create_all()

    yield _db

    # Teardown
    _db.session.remove()
    _db.drop_all()