为了账号安全,请及时绑定邮箱和手机立即绑定

`烧瓶数据库迁移`错误

`烧瓶数据库迁移`错误

catspeake 2021-06-05 15:16:31
我们正在尝试运行 aflask db migrate并flask db upgrade引发以下错误: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环境变量中,但仍然出现错误。任何帮助,将不胜感激。下面是我们的__init__.py代码。我们错过了什么吗?import loggingfrom flask import Flaskfrom 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 Enginefrom 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
查看完整描述

1 回答

?
qq_花开花谢_0

TA贡献1835条经验 获得超7个赞

我想如果你像你一样使用迁移


migrate.init_app(app, db)  

您首先必须导入它然后声明它:


from flask_migrate import Migrate

migrate = Migrate()

migrate.init_app(app, db)

或者我认为你可以这样做:


from flask_migrate import Migrate

migrate = Migrate(app, db) 


查看完整回答
反对 回复 2021-06-06
  • 1 回答
  • 0 关注
  • 120 浏览
慕课专栏
更多

添加回答

举报

0/150
提交
取消
意见反馈 帮助中心 APP下载
官方微信