Python経由でmongoHqデータベースに接続したい。これが私がこれまでに行ったことです
環境変数が設定されます:
MONGOHQ_URL = mongodb://myusername:mypassword@paulo.mongohq.com:10084/mydb
および app.py ファイル
import os
import datetime
import pymongo
from pymongo import MongoClient
MONGO_URL = os.environ.get('MONGOHQ_URL')
client = MongoClient(MONGO_URL)
db = client.mydb
このファイルを実行すると、次のエラーが発生します
Traceback (most recent call last):
File "C:\Python33\lib\site-packages\pymongo-2.6.2-py3.3-win-amd64.egg\pymongo\mongo_client.py", line 349, in __init__
self.__find_node(seeds)
File "C:\Python33\lib\site-packages\pymongo-2.6.2-py3.3-win-amd64.egg\pymongo\mongo_client.py", line 750, in __find_node
raise AutoReconnect(', '.join(errors))
pymongo.errors.AutoReconnect: could not connect to localhost:27017: [WinError 10061] No connection could be made because the target machine actively refused it
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "C:\Python33\flaskk\test.py", line 9, in <module>
client = MongoClient(MONGO_URL)
File "C:\Python33\lib\site-packages\pymongo-2.6.2-py3.3-win- amd64.egg\pymongo\mongo_client.py", line 352, in __init__
raise ConnectionFailure(str(e))
pymongo.errors.ConnectionFailure: could not connect to localhost:27017: [WinError 10061]
No connection could be made because the target machine actively refused it
助けてください !!前もって感謝します !!