Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Database not being created. #158

Open
ScalvyC opened this issue Jul 24, 2024 · 0 comments
Open

Database not being created. #158

ScalvyC opened this issue Jul 24, 2024 · 0 comments

Comments

@ScalvyC
Copy link

ScalvyC commented Jul 24, 2024

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant