我将Python与Flask配合使用,并且试图迁移数据库。我运行flask db init
,得到No handlers could be found for logger "root"
。这是我的主要脚本:
import os
from flask_migrate import Migrate
from app import create_app, db
from app.models import User, Role
from flask_script import Manager
app = create_app(os.getenv('FLASK_CONFIG') or 'default')
migrate = Migrate(app, db)
manager = Manager(app)
app.config.update(dict(
SECRET_KEY="powerful secretkey",
WTF_CSRF_SECRET_KEY="a csrf secret key"
))
@manager.command
def hello():
print("hello")
if __name__ == "__main__":
manager.run()
@app.shell_context_processor
def make_shell_context():
return dict(db=db, User=User, Role=Role)
服务器运行正常,但是我没有数据库,应该迁移它。 您能帮我解决这个问题吗?