sqlalchemy.create_all() got an unexpected keyword argument 'app' error

Question:

new to coding, ive been stuck with this problem for about 4 days now and i have no idea how to get around it, ill paste the coding below

init.py

from flask import Flask
from flask_sqlalchemy import SQLAlchemy
from os import path
from flask_login import LoginManager

db = SQLAlchemy()
DB_NAME = "database.db"


def create_app():
    app = Flask(__name__)
    app.config['SECRET_KEY'] = 'meaty'
    app.config['SQLALCHEMY_DATABASE_URI'] = f'sqlite:///{DB_NAME}'
    db.init_app(app)

    from .views import views
    from .auth import auth

    app.register_blueprint(views, url_prefix='/')
    app.register_blueprint(auth, url_prefix='/')

    from .models import User, Note

    create_database(app)

    login_manager = LoginManager()
    login_manager.login_view = 'auth.login'
    login_manager.init_app(app)

    @login_manager.user_loader
    def load_user(id):
        return User.query.get(int(id))

    return app


def create_database(app, **kwargs):
    if not path.exists('website/' + DB_NAME):
        db.create_all(app=app)
        print('Created Database!')

main.py

from website import create_app

if __name__ == '__main__':
    app = create_app()
    app.run(debug=True)

Errors

errors above

any help is much appreciated

Asked By: bmo

||

Answers:

Categories: questions Tags: ,
Answers are sorted by their score. The answer accepted by the question owner as the best is marked with
at the top-right corner.