本文介绍了烧瓶数据库迁移错误的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我们正在尝试运行 flask数据库迁移和 flask数据库升级,这会引发以下错误:
We are trying to run a flask db migrate and flask db upgrade which throws the following error:
Usage: flask db upgrade [OPTIONS] [REVISION] Error: The file/path provided (C) does not appear to exist. Please verify the path is correct. If app is not on PYTHONPATH, ensure the extension is .py我们已经将应用程序的目录添加到了 PYTHONPATH 环境变量中,但仍然出现错误.任何帮助将不胜感激.
We have added the app's directory to the PYTHONPATH environment variable but still get the error. Any help would be appreciated.
下面是我们的 __ init __.py 代码.我们错过了什么吗?
Below is our __init__.py code. Are we missing something?
import logging from flask import Flask from flask_appbuilder import SQLA, AppBuilder """ Logging configuration """ logging.basicConfig(format='%(asctime)s:%(levelname)s:%(name)s:%(message)s') logging.getLogger().setLevel(logging.DEBUG) app = Flask(__name__) app.config.from_object('config') db = SQLA(app) appbuilder = AppBuilder(app, db.session) migrate.init_app(app, db) """ from sqlalchemy.engine import Engine from sqlalchemy import event #Only include this for SQLLite constraints @event.listens_for(Engine, "connect") def set_sqlite_pragma(dbapi_connection, connection_record): # Will force sqllite contraint foreign keys cursor = dbapi_connection.cursor() cursor.execute("PRAGMA foreign_keys=ON") cursor.close() """ from app import views 推荐答案我认为您是否像使用迁移一样
I think if you are using migrate like you are
migrate.init_app(app, db)您首先必须导入它,然后声明它:
that you first have to import it and then declare it:
from flask_migrate import Migrate migrate = Migrate() migrate.init_app(app, db)或者我认为您可以做到:
or alternatively I think you could do:
from flask_migrate import Migrate migrate = Migrate(app, db)更多推荐
烧瓶数据库迁移错误
发布评论