M
M
Mist82014-11-30 11:32:04
MongoDB
Mist8, 2014-11-30 11:32:04

Why doesn't the Flask-MongoEngine tutorial example work?

I started to learn how to use mongoDB with flask, I open the tutorial, copy the code, start the local server and an error appears:

File "C:\venv\flask_secure\lib\site-packages\mongoengine\connection.py", line 124, in get_connection
    raise ConnectionError("Cannot connect to database %s :\n%s" % (alias, e))
mongoengine.connection.ConnectionError: Cannot connect to database default :
[WinError 10061] Подключение не установлено, т.к. конечный компьютер отверг запрос на подключение


I do everything one to one according to the tutorial from their site

# Set the path
import os, sys
sys.path.append(os.path.abspath(os.path.join(os.path.dirname(__file__), '..')))

from flask.ext.script import Manager, Server
from tumblelog import app

manager = Manager(app)

# Turn on debugger by default and reloader
manager.add_command("runserver", Server(
    use_debugger = True,
    use_reloader = True,
    host = '0.0.0.0')
)

if __name__ == "__main__":
    manager.run()


Python version 3.4, Windows 7, modules - latest.

Answer the question

In order to leave comments, you need to log in

2 answer(s)
R
Rostislav Grigoriev, 2014-11-30
@crazyzubr

In the code above, there are no settings for MongoDB at all.
And it's better to read in the application documentation https://flask-mongoengine.readthedocs.org/en/latest/

M
Mist8, 2014-11-30
@Mist8

Understood. For a long time I could not guess that it was necessary to install the database itself separately. In the tutorials, this seems to be considered obvious.
In general, in order for mongodb to work locally, you need to download it from the off site and run it on your computer.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question