Open ScalvyC opened 1 month ago
Code: "from flask import Flask from flask_sqlalchemy import SQLAlchemy from os import path
db = SQLAlchemy() DB_NAME = "CSIA.db"
def create_app(): app = Flask(name) app.config['SECRET_KEY'] = 'www' 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 Admin, Employees, Product, Order, OrderItem, InventoryPage, Supplier create_database(app) with app.app_context(): db.create_all() return app
def create_database(app): if not path.exists('Website/' + DB_NAME): db.create_all(app=app) print('Created Database!') "
Error: "S D:\MY PC\Documents> & "C:/Program Files/Python312/python.exe" "d:/MY PC/Documents/main.py" Traceback (most recent call last): File "d:\MY PC\Documents\main.py", line 3, in app = create_app() ^^^^^^^^^^^^ File "d:\MY PC\Documents\Website__init.py", line 22, in create_app create_database(app) File "d:\MY PC\Documents\Website\init__.py", line 30, in create_database db.create_all(app=app) TypeError: SQLAlchemy.create_all() got an unexpected keyword argument 'app'"
Code: "from flask import Flask from flask_sqlalchemy import SQLAlchemy from os import path
db = SQLAlchemy() DB_NAME = "CSIA.db"
def create_app(): app = Flask(name) app.config['SECRET_KEY'] = 'www' app.config['SQLALCHEMY_DATABASE_URI'] = f'sqlite:///{DB_NAME}' db.init_app(app)
def create_database(app): if not path.exists('Website/' + DB_NAME): db.create_all(app=app) print('Created Database!') "
Error: "S D:\MY PC\Documents> & "C:/Program Files/Python312/python.exe" "d:/MY PC/Documents/main.py" Traceback (most recent call last): File "d:\MY PC\Documents\main.py", line 3, in
app = create_app()
^^^^^^^^^^^^
File "d:\MY PC\Documents\Website__init.py", line 22, in create_app
create_database(app)
File "d:\MY PC\Documents\Website\init__.py", line 30, in create_database
db.create_all(app=app)
TypeError: SQLAlchemy.create_all() got an unexpected keyword argument 'app'"