我正在使用init_app()初始化mongo连接,但是即使mongo服务器未运行,它也不会给我任何连接错误,但是在使用find提取数据时却出现了错误。
mongo = PyMongo()
def create_app(config_name):
if config_name is None:
config_name = os.environ.get('FLASK_CONFIG', 'development')
app = Flask(__name__, instance_relative_config=True)
app.url_map.strict_slashes = False
app.config.from_object(app_config[config_name])
configInstance = app_config[config_name]()
app.config.from_pyfile(configInstance.FLASK_CONFIG)
try:
mongo.init_app(app)
except PyMongo.errors.ConnectionFailure as e:
print ("connection gives pymongo.errors.ConnectionFailure --- %s" % (e.message))
给出以下错误
localhost:27017: [Errno 111] Connection refused