I have a MongoDB database hosted on mlab and I would like to use PyMODM as my object modeling library.
This is my code so far:
from pymodm import connect, MongoModel, fields
connect = connect('mongodb://user:pass@ds119788.mlab.com/db')
class Test(MongoModel):
user = fields.CharField()
if __name__ == "__main__":
test = Test("test")
test.save()
But it gives me this error :
pymongo.errors.ServerSelectionTimeoutError: ds119788.mlab.com:27017: [Errno 61] Connection refused
Am I missing something?
You need to use the MongoDB URI provided by mlab
for your account. The URI should contain the port number to connect to.
For example, it should look like :
connect = connect('mongodb://user:password@ds119788.mlab.com:63123/databaseName')