i'm a beginner and i've encountered a problem... I've made changes to my db.py file and i'm importing it to main.py. when i try to flask-migrate i get this error:
"Error: Could not locate a Flask application. Use the 'flask --app' option, 'FLASK_APP' environment variable, or a 'wsgi.py' or 'app.py' file in the current directory. Error: No such command 'db'"
on the other hand, if i have my db in the same file as my main it works... why?
db.py:
from flask_sqlalchemy import SQLAlchemy
from flask import Flask
# SUBSCRIBE DATABASE
class Subscribe(db.Model):
id = db.Column(db.Integer, primary_key=True)
email = db.Column(db.String(120), unique=True, nullable=False)
name = db.Column(db.String(120), nullable=False)
# CREATE ALL DB
def init_db(app):
with app.app_context():
db.init_app(app)
db.create_all()
main.py:
from flask_bootstrap import Bootstrap5
from flask_migrate import Migrate
# import db.py
from db import db, Subscribe, init_db
# FLASK CONFIGURATION
app = Flask(__name__)
app.config['SECRET_KEY'] = 'SECRET-KEY-HERE'
app.config['SQLALCHEMY_DATABASE_URI'] = 'sqlite:///posts.db'
ckeditor = CKEditor(app)
Bootstrap5(app)
# load db config
init_db(app)
migrate = Migrate(app, db)