I tried to insert data into mongodb without using models. When I run script I have got below error ,
TypeError: get_db_handle() missing 1 required positional argument: 'password'
this is my query.py
class Department(object):
print(object)
def import_department(self):
data = ["IT", "FINANCE", "HR"]
db_handle = self.get_db_handle(EVENT_STORE_DICT.get("DB_NAME"),
EVENT_STORE_DICT.get("DB_HOST"),
EVENT_STORE_DICT.get("DB_PORT"),
EVENT_STORE_DICT.get("USERNAME"),
EVENT_STORE_DICT.get("PASSWORD"))
department_insert = self.insert_into_db(db_handle, data)
if __name__ == '__main__':
Department.import_department(DBMixin)
here, db handled method,
class DBMixin(object):
def get_db_handle(self, db_name, host, port, username, password)
client = MongoClient(host=host,
port=int(port),
username='',
password=''
)
db_handle = client[db_name]
return db_handle
How can i solve this problem. Please help me out..
CodePudding user response:
get_db_handle
is a method of class DBMixin
but you are calling it from class Department
as self.get_db_handle().