class MongoConnect(object): def __init__(self,HOST,PORT,DB,USERNAME,PASSSWORD): self.HOST=HOST self.PORT=PORT self.USERNAME=USERNAME self.PASSSWORD=PASSSWORD self.DB=DB def getMongoConnetion(self): client= MongoClient(self.HOST, self.PORT, username=self.USERNAME, password=self.PASSSWORD) return client
def getDBObject(self, DB): connection = getMongoConnetion() return connection[DB].authenticate(USERNAME,PASSSWORD) MONGO_DB = 'techcraft' instance=MongoConnect('127.0.0.1',27017,'techcraft','craft','dbcl123456') client=instance.getMongoConnetion() db=instance.getDBObject('techcraft') print(db) ############Error########## Traceback (most recent call last): File "self.py", line 36, in <module> db=instance.getDBObject('techcraft') File "self.py", line 28, in getDBObject connection = getMongoConnetion() NameError: name 'getMongoConnetion' is not defined -- The information in this e-mail and any attachments is confidential and may be legally privileged. It is intended solely for the addressee or addressee's. If you are not an intended recipient, please delete the message and any attachments and notify the sender of nondelivery. Any use or disclosure of the contents of either is unauthorised and may be unlawful. All liability for viruses is excluded to the fullest extent permitted by law. Any views expressed in this message are those of the individual sender, except where the sender states them, with requisite authority, to be those of the organisation. -- You received this message because you are subscribed to the Google Groups "Django users" group. To unsubscribe from this group and stop receiving emails from it, send an email to django-users+unsubscr...@googlegroups.com. To view this discussion on the web visit https://groups.google.com/d/msgid/django-users/855f8f95-0175-4983-b667-439d7935c39e%40googlegroups.com.