我现在按照FlaskWeb开发实战上面的例子进行学习,但是书上用的是sqlite做的数据库,现在改用mysql连接,这是我的项目结构
我在config文件中这样配置了数据库的路径
class DevelopmentConfig:
# SQLALCHEMY_URL =
DEBUG = True
SQLALCHEMY_DATABASE_URI = 'mysql://root:5407922@localhost:3306/comblog'
SECRET_KEY = 'asdasdasd'
SQLALCHEMY_TRACK_MODIFICATIONS = True
@staticmethod
def init_app(app):
pass
然后在app/__init__.py中按照实际的config类别进行初始化(这里我调用的都是DevelopmentConfig类),代码如下:
def create_app(config_name):
"""
The blueprint for the /app/auth
visit the http://IP:PORT/auth/login (This route is in the /app/auth/views.py)
"""
app = Flask(__name__)
app.config.from_object(config[config_name])
config[config_name].init_app(app)
login_manager.init_app(app)
bootstrap.init_app(app)
db.init_app(app)
from .auth import auth as auth_blurprint
app.register_blueprint(auth_blurprint, url_prefix='/auth')
return app
现在的问题是每次我进行查询操作后,服务器就崩掉了,而且不会有任何的debug信息,不知道怎么回事儿,求教。
你改成mysql后,可能没新建mysql里面的表吧