起初我试过了:
import pymongo
MONGOHQ_URL = "mongodb://username:password@kahana.mongohq.com:10025/dbname"
conn = pymongo.MongoClient(MONGOHQ_URL)
但显然它失败了并且它抛出了以下错误:
Traceback (most recent call last):
File "bot.py", line 95, in <module>
conn = pymongo.Connection(MONGOHQ_URL)
File "/var/lib/openshift/53abb500028e/python/virtenv/lib/python2.7/site-packages/pymongo/connection.py", line 236, in __init__
max_pool_size, document_class, tz_aware, _connect, **kwargs)
File "/var/lib/openshift/53abb500028e/python/virtenv/lib/python2.7/site-packages/pymongo/mongo_client.py", line 369, in __init__
raise ConnectionFailure(str(e))
pymongo.errors.ConnectionFailure: [Errno 13] Permission denied
他们有一个例子,但它在Ruby中,我不知道。如果我没错,我猜这个连接是在this脚本中发生的。
任何人都可以从这个ruby代码中解决并帮助我,以便我可以在我的python脚本中使用pymongo吗?我已经设置了环境变量MONGO_URL