Skip to content

Database not being created. #158

@ScalvyC

Description

@ScalvyC

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'"

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions