生产环境访问不到数据库
来源:16-1 单进程启动服务

数据云团
2020-12-25
在 application 中该如何配置
class Application(Flask): def __init__(self, import_name, template_folder=None, root_path=None): super(Application, self).__init__(import_name=import_name, template_folder=template_folder, root_path=root_path, static_folder=None) self.config.from_pyfile('config/base_setting.py') # export ops_config=local # python manager.py runserver if 'ops_config' in os.environ: self.config.from_pyfile('config/%s_setting.py' % os.environ['ops_config']) db.init_app(self)
写回答
1回答
-
编程浪子
2020-12-25
你好
这个代码没有任何问题,首先 你有对应环境的配置文件有没有? 其实 设置了对应环境变量有没有(linux 系统 export ops_config=xxxx windows set ops_config=xxxx)
生产环境一般是 production 对应的配置文件就是 config/production_setting.py
022020-12-25
相似问题