0

At first I tried:

import pymongo
MONGOHQ_URL = "mongodb://username:password@kahana.mongohq.com:10025/dbname"
conn = pymongo.MongoClient(MONGOHQ_URL)

but apparently it failed and it throws following error:

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

They have an example, but it's in Ruby and I have no idea. If I am not wrong, I guess the connection is happening in this script.

Can anyone makeout from this ruby code and help me so that I can use in my python script with pymongo? I have already set environment variable MONGO_URL

avi
  • 9,292
  • 11
  • 47
  • 84
  • You'll want to check out the answer provided in this post http://stackoverflow.com/questions/22274745/openshift-python-mongodb-environment-variables-not-set-cant-connect – niharvey Jun 26 '14 at 13:56
  • @niharvey its different, he is asking how to connect to MongoDB which is provided by Open Shift, not mongo hq. – avi Jun 26 '14 at 14:00
  • Can you share more of your code as well as the URI that (I assume) you are assigning to your MONGOHQ_URL? If you are seeing a permissions error, it could be incorrect auth being passed or attempting to access the wrong database. – Jason McCay Jun 26 '14 at 19:53

0 Answers0