July 2019
Beginner to intermediate
302 pages
9h 38m
English
The new directory layout would appear as follows:
flask_catalog/
- run.py my_app/
- __init__.py
catalog/
- __init__.py
- views.py
- models.py
First of all, start with modifying the application configuration file, that is, flask_catalog/my_app/__init__.py:
from flask import Flask from flask_sqlalchemy import SQLAlchemy app = Flask(__name__) app.config['SQLALCHEMY_DATABASE_URI'] = 'sqlite:////tmp/test.db' db = SQLAlchemy(app) from my_app.catalog.views import catalog app.register_blueprint(catalog) db.create_all()
The last statement in the file is db.create_all(), which tells the application to create all the tables in the database specified. So, as soon as the application runs, all the tables will be created if they are not ...