📜  烧瓶放置 db.create_all 的位置 - Python 代码示例

📅  最后修改于: 2022-03-11 14:45:58.145000             🧑  作者: Mango

代码示例1
# This file initializes your application and brings together all of the various components.

# TL;DR: db.create_all(app=app)

from flask import Flask
from .views import mainRoutes    # This just imports my URL-routes
from .extensions import db        # Creates db in another file

app = Flask(__name__)

app.config.from_pyfile('../settings.py')    # Separate file to configure your app

db.init_app(app)
db.create_all(app=app)            # THIS IS THE CRITICAL SOLUTION

app.register_blueprint(mainRoutes)

from DatabaseTest import views # import down here to prevent circular imports