i am using init_app() to initialize mongo connection but it won't give me any error at connection despite mongo server is not running, but gives error when fetching the data using 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))
gives below error
localhost:27017: [Errno 111] Connection refused