Decrypt the error connecting the mongo instance hosted in <project> .meteor.com
I would like to use python to connect to the mongo instance bound to the meteor application hosted on meteor.com. I got the url for my application using the meteor mongo -U <appname> and I can connect. However, when I connect and try to do something simple (list the documents in the "slides" collection), I get an error message:
In [1]: import pymongo In [2]: con = pymongo.Connection("mongodb://client:f066d336-f5bd-1a85-1039-c679fbb645a1@skybreak.member0.mongolayer.com:27017/slides_meteor_com").meteor In [3]: con.slides.find() Out[3]: <pymongo.cursor.Cursor at 0x109873690> In [4]: [ x for x in con.slides.find() ] --------------------------------------------------------------------------- OperationFailure Traceback (most recent call last) /Users/bensonk/Code/lfnw-elite-talk/<ipython-input-4-2112945d50ca> in <module>() ----> 1 [ x for x in con.slides.find() ] /Library/Python/2.7/site-packages/pymongo/cursor.pyc in next(self) 701 raise StopIteration 702 db = self.__collection.database --> 703 if len(self.__data) or self._refresh(): 704 if self.__manipulate: 705 return db._fix_outgoing(self.__data.pop(0), self.__collection) /Library/Python/2.7/site-packages/pymongo/cursor.pyc in _refresh(self) 664 self.__skip, ntoreturn, 665 self.__query_spec(), self.__fields, --> 666 self.__uuid_subtype)) 667 if not self.__id: 668 self.__killed = True /Library/Python/2.7/site-packages/pymongo/cursor.pyc in __send_message(self, message) 626 response = helpers._unpack_response(response, self.__id, 627 self.__as_class, --> 628 self.__tz_aware) 629 except AutoReconnect: 630 db.connection.disconnect() /Library/Python/2.7/site-packages/pymongo/helpers.pyc in _unpack_response(response, cursor_id, as_class, tz_aware) 99 raise AutoReconnect("master has changed") 100 raise OperationFailure("database error: %s" % --> 101 error_object["$err"]) 102 103 result = {} OperationFailure: database error: unauthorized db:meteor lock type:-1 client:173.160.192.81 From what I can say, this is a mongo, suggesting that I do not have read access from this collection. I can read this from the mongo console via meteor mongo <projectname , but not from python. How can I read from it in python?
It looks like your database uses authentication, and you did not provide a username / password. In python, this is done using db.authenticate(username, password) . Details here: http://api.mongodb.org/python/2.1.1/api/pymongo/database.html