def on_post(self, req, resp): """Handles POST requests""" output_dict = {"msgHeader": {"authToken": ""}, "data": {"updated": ""}} errors = utils.errors success = "company group successfully created" try: raw_json = req.stream.read() input_dict = json.loads(raw_json, encoding='utf-8') except Exception as ex: raise falcon.HTTPError(falcon.HTTP_400, 'Invalid JSON', 'The JSON was incorrect.') try: if not validate.Request(api='companyGroup', request=input_dict): output_dict["data"].update({"error": 1, "message": errors["json"]}) resp.body = json.dumps(output_dict) else: db = DB(input_dict["msgHeader"]["authLoginID"]) val_error = validate(db).basicChecks(token=input_dict["msgHeader"]["authToken"]) if val_error: output_dict["data"].update({"error": 1, "message": val_error}) resp.body = json.dumps(output_dict) else: indict = input_dict["data"] #compGrp = Table("mw_company_group", schema="mint_loan") compMaster = Table("mw_company_master",schema="mint_loan") #compCityMap = Table("mw_company_city_mapping", schema="mint_loan") #compDocMap = Table("mw_company_document_mapping",schema="mint_loan") #compCityProdMap = Table("mw_company_city_product_mapping",schema="mint_loan") #compOtherMap = Table("mw_company_other_details_mapping" ,schema="mint_loan") #created_date=(datetime.utcnow() + timedelta(seconds=19800)).strftime("%Y-%m-%d %H:%M:%S") q1=Query.from_(compMaster).select(compMaster.SHORT_NAME).where(compMaster.AUTO_ID==input_dict["data"]["companyID"]) companyName=db.runQuery(q1)["data"] if companyName!=[]: inserted = db.Insert(db="mint_loan", table="mw_company_city_mapping", compulsory=False,date=False, **utils.mergeDicts({"COMPANY_NAME":input_dict["data"]["companyName"] if input_dict["data"]["companyName"] else None, "COMPANY_ID":input_dict["data"]["companyID"] if input_dict["data"]["companyID"] else None, "DOCUMENT_ID":input_dict["data"]["documentID"] if input_dict["data"]["documentID"] else None, "CREATED_BY":input_dict["msgHeader"]["authLoginID"], "CREATED_DATE":datetime.now().strftime("%Y-%m-%d %H:%M:%S")}))#(datetime.utcnow() + timedelta(seconds=19800)).strftime("%Y-%m-%d %H:%M:%S")) token = generate(db).AuthToken() if token["updated"]: output_dict["data"].update({"error": 0, "message": "document mapped successfully"}) output_dict["msgHeader"]["authToken"] = token["token"] else: output_dict["data"].update({"error": 1, "message": errors["token"]}) else: token = generate(db).AuthToken() output_dict["data"].update({"error": 0, "message": "document "}) output_dict["msgHeader"]["authToken"] = token["token"] resp.body = json.dumps(output_dict) db._DbClose_() except Exception as ex: # falcon.HTTPError(falcon.HTTP_400,'Invalid JSON', 'The JSON was incorrect.') raise
def on_post(self, req, resp): """Handles POST requests""" output_dict = {"msgHeader": {"authToken": ""}, "data": {}} errors = utils.errors #success = "company group successfully created" try: raw_json = req.stream.read() input_dict = json.loads(raw_json, encoding='utf-8') except Exception as ex: raise falcon.HTTPError(falcon.HTTP_400, 'Invalid JSON', 'The JSON was incorrect.') try: if not validate.Request(api='companyGroup', request=input_dict): output_dict["data"].update({"error": 1, "message": errors["json"]}) resp.body = json.dumps(output_dict) else: db = DB(input_dict["msgHeader"]["authLoginID"]) val_error = validate(db).basicChecks(token=input_dict["msgHeader"]["authToken"]) if val_error: output_dict["data"].update({"error": 1, "message": val_error}) resp.body = json.dumps(output_dict) else: #loginID = input_dict["data"]["loginID"] cityMaster=Table("mw_city_master",schema="mint_loan") #compGrp = Table("mw_company_group", schema="mint_loan") #compMaster = Table("mw_company_master",schema="mint_loan") #compCityMap = Table("mw_company_city_mapping", schema="mint_loan") #compDocMap = Table("mw_company_document_mapping",schema="mint_loan") #compCityProdMap = Table("mw_company_city_product_mapping",schema="mint_loan") #compOtherMap = Table("mw_company_other_details_mapping" ,schema="mint_loan") kyc = Table("mw_kyc_document_type",schema="mint_loan") #created_date=(datetime.utcnow() + timedelta(seconds=19800)).strftime("%Y-%m-%d %H:%M:%S") q1=Query.from_(kyc).select(kyc.DOCUMENT_TYPE_ID,kyc.DOCUMENT_TYPE,kyc.DOCUMENT_GROUP) doc=db.runQuery(q1)["data"] if doc!=[]: token = generate(db).AuthToken() if token["updated"]: output_dict["data"].update({"error": 0, "message": "document details found","doc":doc}) output_dict["msgHeader"]["authToken"] = token["token"] else: output_dict["data"].update({"error": 1, "message": errors["token"]}) else: token = generate(db).AuthToken() output_dict["data"].update({"error": 0, "message":"document details not found"}) output_dict["msgHeader"]["authToken"] = token["token"] resp.body = json.dumps(output_dict) db._DbClose_() except Exception as ex: # falcon.HTTPError(falcon.HTTP_400,'Invalid JSON', 'The JSON was incorrect.') raise
def on_post(self, req, resp): """Handles POST requests""" output_dict = {"msgHeader": {"authToken": ""}, "data": {}} errors = utils.errors success = "company group successfully created" try: raw_json = req.stream.read() input_dict = json.loads(raw_json, encoding='utf-8') except Exception as ex: raise falcon.HTTPError(falcon.HTTP_400, 'Invalid JSON', 'The JSON was incorrect.') try: if not validate.Request(api='companyGroup', request=input_dict): output_dict["data"].update({ "error": 1, "message": errors["json"] }) resp.body = json.dumps(output_dict) else: db = DB(input_dict["msgHeader"]["authLoginID"]) val_error = validate(db).basicChecks( token=input_dict["msgHeader"]["authToken"]) if val_error: output_dict["data"].update({ "error": 1, "message": val_error }) resp.body = json.dumps(output_dict) else: #loginID = input_dict["data"]["loginID"] compGrp = Table("mw_company_group", schema="mint_loan") compMaster = Table("mw_company_master", schema="mint_loan") #cityMaster =Table("mw_city_master",schema="mint_loan") #compCityMap = Table("mw_company_city_mapping", schema="mint_loan") #compDocMap = Table("mw_company_document_mapping",schema="mint_loan") #compCityProdMap = Table("mw_company_city_product_mapping",schema="mint_loan") #compOtherMap = Table("mw_company_other_details_mapping" ,schema="mint_loan") #kyc=Table("mw_kyc_document_type",schema="mint_loan") q1 = Query.from_(compMaster).join( compGrp, how=JoinType.left).on( compGrp.ID == compMaster.GROUP_ID).select( compMaster.SHORT_NAME, compMaster.DISPLAY_NAME, compMaster.COMPANY_NAME, compMaster.GROUP_ID, compGrp.GROUP_NAME) company = db.runQuery(q1)["data"] #print(company) q2 = Query.from_(compGrp).select('*') cmGroup = db.runQuery(q2)["data"] print(cmGroup) if True: token = generate(db).AuthToken() if token["updated"]: #output_dict["data"]["updated"] = company output_dict["data"].update({ "company": company, "group": cmGroup }) output_dict["data"].update({ "error": 0, "message": success }) output_dict["msgHeader"]["authToken"] = token["token"] else: output_dict["data"].update({ "error": 1, "message": errors["token"] }) resp.body = json.dumps(output_dict) db._DbClose_() except Exception as ex: # falcon.HTTPError(falcon.HTTP_400,'Invalid JSON', 'The JSON was incorrect.') raise
def on_post(self, req, resp): """Handles POST requests""" output_dict = {"msgHeader": {"authToken": ""}, "data": {"products": {}}} errors = utils.errors success = "data loaded successfully" try: raw_json = req.stream.read() input_dict = json.loads(raw_json, encoding='utf-8') # print input_dict except Exception as ex: raise falcon.HTTPError( falcon.HTTP_400, 'Invalid JSON', 'The JSON was incorrect.') try: if False: # not validate.Request(api='', request=input_dict): output_dict["data"].update( {"error": 1, "message": errors["json"]}) resp.body = json.dumps(output_dict) else: db = DB(input_dict["msgHeader"]["authLoginID"]) val_error = validate(db).basicChecks( token=input_dict["msgHeader"]["authToken"], checkToken=False) if val_error: output_dict["data"].update( {"error": 1, "message": val_error}) resp.body = json.dumps(output_dict) else: custID = input_dict["data"]["customerID"] cl = Table("mw_finflux_client_master", schema="mint_loan") lmt = Table("mw_client_loan_limit", schema="mint_loan") prod = Table("mw_finflux_loan_product_master", schema="mint_loan") prof = Table("mw_client_profile", schema="mint_loan") ll = db.runQuery(Query.from_(lmt).select( "LOAN_LIMIT", "MOBILE_LOAN_LIMIT").where(lmt.CUSTOMER_ID == custID))["data"] products = [] if (ll[0]["LOAN_LIMIT"] > 0 if ll else False): # q = Query.from_(prod).select("AUTO_ID", "PRODUCT_ID", "LENDER", # "COMPANIES_MAPPED").where((prod.MAX_PRINCIPLE>=ll[0]["LOAN_LIMIT"]) & # (prod.MIN_PRINCIPLE<=ll[0]["LOAN_LIMIT"]) & # (prod.LIMIT_TYPE=="LOAN_LIMIT")) #products += db.runQuery(q)["data"] q = Query.from_(prod).select("AUTO_ID", "PRODUCT_ID", "LENDER", "COMPANIES_MAPPED").where((prod.MIN_PRINCIPLE <= ll[0]["LOAN_LIMIT"]) & (prod.LIMIT_TYPE == "LOAN_LIMIT")) products += db.runQuery(q)["data"] #products = list(set(products)) if (ll[0]["MOBILE_LOAN_LIMIT"] > 0 if ll else False): q = Query.from_(prod).select("AUTO_ID", "PRODUCT_ID", "LENDER", "COMPANIES_MAPPED").where((prod.MAX_PRINCIPLE >= ll[0]["MOBILE_LOAN_LIMIT"]) & (prod.MIN_PRINCIPLE <= ll[0]["MOBILE_LOAN_LIMIT"]) & (prod.LIMIT_TYPE == "MOBILE_LOAN_LIMIT")) products += db.runQuery(q)["data"] # print products listed_companies = sum([json.loads(ele["COMPANIES_MAPPED"] if ele["COMPANIES_MAPPED"] is not None else "[]") for ele in db.runQuery(Query.from_(prod).select("COMPANIES_MAPPED"))["data"]], []) finalProducts = [] q = db.runQuery(Query.from_(prof).select( prof.COMPANY_NAME).where(prof.CUSTOMER_ID == custID)) comp = q["data"][0]["COMPANY_NAME"] if q["data"] else "" qq = db.runQuery(Query.from_(cl).select(cl.CLIENT_ID).where( (cl.CUSTOMER_ID == custID) & (cl.LENDER == 'GETCLARITY')))["data"] for ele in products: if (ele["LENDER"] == "GETCLARITY"): if (comp in (json.loads(ele["COMPANIES_MAPPED"])) if ele["COMPANIES_MAPPED"] is not None else True): if (str(ele["PRODUCT_ID"]) != "5"): finalProducts.append( {"AUTO_ID": ele["AUTO_ID"], "PRODUCT_ID": ele["PRODUCT_ID"], "LENDER": "GETCLARITY"}) elif (ll[0]["LOAN_LIMIT"] == 2500 if ll else False) or (len(qq) > 0): finalProducts.append( {"AUTO_ID": ele["AUTO_ID"], "PRODUCT_ID": ele["PRODUCT_ID"], "LENDER": "GETCLARITY"}) if (ele["LENDER"] == "CHAITANYA") & (comp not in listed_companies): finalProducts.append( {"AUTO_ID": ele["AUTO_ID"], "PRODUCT_ID": ele["PRODUCT_ID"], "LENDER": "CHAITANYA"}) if True: # token["updated"]: output_dict["data"]["products"] = finalProducts output_dict["data"].update( {"error": 0, "message": success}) # token["token"] output_dict["msgHeader"]["authToken"] = input_dict["msgHeader"]["authToken"] else: output_dict["data"].update( {"error": 1, "message": errors["token"]}) # print output_dict resp.body = json.dumps(output_dict) db._DbClose_() except Exception as ex: # falcon.HTTPError(falcon.HTTP_400,'Invalid JSON', 'The JSON was incorrect.') raise
def on_post(self, req, resp): """Handles POST requests""" output_dict = {"msgHeader": {"authToken": ""}, "data": {}} errors = utils.errors success = "company group successfully created" try: raw_json = req.stream.read() input_dict = json.loads(raw_json, encoding='utf-8') except Exception as ex: raise falcon.HTTPError(falcon.HTTP_400, 'Invalid JSON', 'The JSON was incorrect.') try: if not validate.Request(api='companyGroup', request=input_dict): output_dict["data"].update({ "error": 1, "message": errors["json"] }) resp.body = json.dumps(output_dict) else: db = DB(input_dict["msgHeader"]["authLoginID"]) val_error = validate(db).basicChecks( token=input_dict["msgHeader"]["authToken"]) if val_error: output_dict["data"].update({ "error": 1, "message": val_error }) resp.body = json.dumps(output_dict) else: #loginID = input_dict["data"]["loginID"] compGrp = Table("mw_company_group", schema="mint_loan") #compMaster = Table("mw_company_master",schema="mint_loan") #compCityMap = Table("mw_company_city_mapping", schema="mint_loan") #compDocMap = Table("mw_company_document_mapping",schema="mint_loan") #compCityProdMap = Table("mw_company_city_product_mapping",schema="mint_loan") #compOtherMap = Table("mw_company_other_details_mapping" ,schema="mint_loan") #created_date=(datetime.utcnow() + timedelta(seconds=19800)).strftime("%Y-%m-%d %H:%M:%S") if db.Query(primaryTable="mw_company_master", fields={"A": ["*"]}, conditions={ "SHORT_NAME =": input_dict["data"]["shortName"] }, Data=False)["count"] == 0: q1 = Query.from_(compGrp).select( compGrp.ID).where(compGrp.GROUP_NAME == input_dict["data"]["groupName"]) groupID = db.runQuery(q1) if groupID["data"]: groupId = str(groupID["data"][0]["ID"]) else: groupId = None print(groupId) inserted = db.Insert( db="mint_loan", table="mw_company_master", compulsory=False, date=False, **utils.mergeDicts({ "SHORT_NAME": input_dict["data"]["shortName"] if input_dict["data"]["groupName"] else None, "DISPLAY_NAME": input_dict["data"]["displayName"] if input_dict["data"]["displayName"] else None, "COMPANY_NAME": input_dict["data"]["companyName"] if input_dict["data"]["companyName"] else None, "PAN_NUMBER": input_dict["data"]["panNumber"] if input_dict["data"]["panNumber"] else None, "IS_VENDOR": input_dict["data"]["isVendor"] if input_dict["data"]["isVendor"] else None, "PREFERRED": input_dict["data"]["preferred"] if input_dict["data"]["preferred"] else None, "ICON_URL": input_dict["data"]["iconUrl"] if input_dict["data"]["iconUrl"] else None, "OTHER_DETAILS_WEB_URL": input_dict["data"]["webUrl"] if input_dict["data"]["webUrl"] else '', "GROUP_ID": str(groupId), "CREATED_BY": input_dict["msgHeader"]["authLoginID"], "CREATED_DATE": datetime.now().strftime("%Y-%m-%d %H:%M:%S") })) token = generate(db).AuthToken() if token["updated"] and inserted: #output_dict["data"]["updated"] = updated output_dict["data"].update({ "error": 0, "message": "company added successfully" }) output_dict["msgHeader"]["authToken"] = token[ "token"] else: output_dict["data"].update({ "error": 1, "message": errors["token"] }) else: token = generate(db).AuthToken() output_dict["data"].update({ "error": 0, "message": "company already exist" }) output_dict["msgHeader"]["authToken"] = token["token"] resp.body = json.dumps(output_dict) db._DbClose_() except Exception as ex: # falcon.HTTPError(falcon.HTTP_400,'Invalid JSON', 'The JSON was incorrect.') raise
def on_post(self, req, resp): """Handles POST requests""" output_dict = {"msgHeader": {"authToken": ""}, "data": {}} errors = utils.errors success = "company group successfully created" try: raw_json = req.stream.read() input_dict = json.loads(raw_json, encoding='utf-8') except Exception as ex: raise falcon.HTTPError(falcon.HTTP_400, 'Invalid JSON', 'The JSON was incorrect.') try: if not validate.Request(api='companyGroup', request=input_dict): output_dict["data"].update({ "error": 1, "message": errors["json"] }) resp.body = json.dumps(output_dict) else: db = DB(input_dict["msgHeader"]["authLoginID"]) val_error = validate(db).basicChecks( token=input_dict["msgHeader"]["authToken"]) if val_error: output_dict["data"].update({ "error": 1, "message": val_error }) resp.body = json.dumps(output_dict) else: #loginID = input_dict["data"]["loginID"] compGrp = Table("mw_company_group", schema="mint_loan") compMaster = Table("mw_company_master", schema="mint_loan") cityMaster = Table("mw_city_master", schema="mint_loan") compCityMap = Table("mw_company_city_mapping", schema="mint_loan") compDocMap = Table("mw_company_document_mapping", schema="mint_loan") compCityProdMap = Table("mw_company_city_product_mapping", schema="mint_loan") compOtherMap = Table("mw_company_other_details_mapping", schema="mint_loan") kyc = Table("mw_kyc_document_type", schema="mint_loan") #created_date=(datetime.utcnow() + timedelta(seconds=19800)).strftime("%Y-%m-%d %H:%M:%S") q1 = Query.from_(compGrp).select(compGrp.ID).where( compGrp.GROUP_NAME == input_dict["data"]["groupName"]) groupID = db.runQuery(q1) if groupID["data"]: groupId = groupID["data"][0]["ID"] else: groupId = None #print(groupId) q2 = Query.from_(compMaster).select('*').where( compMaster.GROUP_ID == groupId) company = db.runQuery(q2) companyShortName = list( ele["SHORT_NAME"] for ele in company["data"]) if company["data"] else None print(companyShortName) join = Query.from_(cityMaster).join( compCityMap, how=JoinType.inner).on_field("CITY_ID").select( cityMaster.CITY, compCityMap.CITY_ID, compCityMap.COMPANY_SHORT_NAME, compCityMap.INSURANCE_ENABLED) q3 = join.where( compCityMap.COMPANY_SHORT_NAME.isin(companyShortName)) cityData = db.runQuery(q3) join = Query.from_(kyc).join( compDocMap, how=JoinType.inner).on(kyc.DOCUMENT_TYPE_ID == compDocMap.DOCUMENT_ID).select( compDocMap.DOCUMENT_ID, kyc.DOCUMENT_TYPE, compDocMap.COMPANY_ID, compDocMap.COMPANY_NAME, compDocMap.UPFRONT_REQUIRED) q4 = join.where( compDocMap.COMPANY_NAME.isin(companyShortName)) docData = db.runQuery(q4) if True: token = generate(db).AuthToken() if token["updated"]: #output_dict["data"]["updated"] = company output_dict["data"].update({ "city": cityData["data"], "document": docData["data"], "company": company["data"] }) output_dict["data"].update({ "error": 0, "message": success }) output_dict["msgHeader"]["authToken"] = token["token"] else: output_dict["data"].update({ "error": 1, "message": errors["token"] }) resp.body = json.dumps(output_dict) db._DbClose_() except Exception as ex: # falcon.HTTPError(falcon.HTTP_400,'Invalid JSON', 'The JSON was incorrect.') raise
def on_post(self, req, resp): """Handles POST requests""" output_dict = {"msgHeader": {"authToken": ""}, "data": {}} errors = utils.errors success = "company group successfully created" try: raw_json = req.stream.read() input_dict = json.loads(raw_json, encoding='utf-8') except Exception as ex: raise falcon.HTTPError(falcon.HTTP_400, 'Invalid JSON', 'The JSON was incorrect.') try: if False: #not validate.Request(api='companyGroup', request=input_dict): output_dict["data"].update({ "error": 1, "message": errors["json"] }) resp.body = json.dumps(output_dict) else: db = DB(input_dict["msgHeader"]["authLoginID"]) val_error = validate(db).basicChecks( token=input_dict["msgHeader"]["authToken"]) if val_error: output_dict["data"].update({ "error": 1, "message": val_error }) resp.body = json.dumps(output_dict) else: indict = input_dict["data"] #compGrp = Table("mw_company_group", schema="mint_loan") compMaster = Table("mw_company_master", schema="mint_loan") cityMaster = Table("mw_city_master", schema="mint_loan") compCityMap = Table("mw_company_city_mapping", schema="mint_loan") #compDocMap = Table("mw_company_document_mapping",schema="mint_loan") #compCityProdMap = Table("mw_company_city_product_mapping",schema="mint_loan") #compOtherMap = Table("mw_company_other_details_mapping" ,schema="mint_loan") #created_date=(datetime.utcnow() + timedelta(seconds=19800)).strftime("%Y-%m-%d %H:%M:%S") #join = Query.from_(cityMaster).join(compCityMap,how=JoinType.inner).on_field("CITY_ID").select(functions.Count(compCityMap.CITY_ID).as_("cityCount")) #q3=join.where((cityMaster.CITY==input_dict["data"]["city"]) &(compCityMap.COMPANY_SHORT_NAME==input_dict["data"]["shortName"])) #cityCount=db.runQuery(q3)["data"] #print(cityCount) #cityExist= cityCount[0]["cityCount"] if cityCount!=[] else 0 #print(cityExist) q1 = Query.from_(compCityMap).select( compCityMap.COMPANY_SHORT_NAME).where( compCityMap.CITY_ID == input_dict["data"] ["cityID"]) companyName = db.runQuery(q1)["data"] if companyName == []: #city_id=db.runQuery(Query.from_(cityMaster).select(cityMaster.CITY_ID).where(cityMaster.CITY==input_dict["data"]["city"]))["data"] #print(city_id) inserted = db.Insert( db="mint_loan", table="mw_company_city_mapping", compulsory=False, date=False, **utils.mergeDicts({ "COMPANY_SHORT_NAME": input_dict["data"]["companyShortName"] if input_dict["data"]["companyShortName"] else None, "CITY_ID": input_dict["data"]["cityID"] if input_dict["data"]["cityID"] else None, "INSURANCE_ENABLED": 0, "CREATED_BY": input_dict["msgHeader"]["authLoginID"], "CREATED_DATE": datetime.now().strftime("%Y-%m-%d %H:%M:%S") }) ) #(datetime.utcnow() + timedelta(seconds=19800)).strftime("%Y-%m-%d %H:%M:%S") token = generate(db).AuthToken() if token["updated"] and inserted: output_dict["data"].update({ "error": 0, "message": "city mapped successfully" }) output_dict["msgHeader"]["authToken"] = token[ "token"] else: output_dict["data"].update({ "error": 1, "message": errors["token"] }) else: token = generate(db).AuthToken() output_dict["data"].update({ "error": 0, "message": "city already mapped" }) output_dict["msgHeader"]["authToken"] = token["token"] resp.body = json.dumps(output_dict) db._DbClose_() except Exception as ex: # falcon.HTTPError(falcon.HTTP_400,'Invalid JSON', 'The JSON was incorrect.') raise
def on_post(self, req, resp): """Handles POST requests""" output_dict = { "msgHeader": { "authToken": "" }, "data": { "citiesAvailable": [] } } errors = utils.errors success = "Available cities laoded successfully" #logInfo = {'api': 'customerDetails'} try: raw_json = req.stream.read() input_dict = json.loads(raw_json, encoding='utf-8') #utils.logger.debug("Request: " + json.dumps(input_dict), extra=logInfo) except Exception as ex: raise falcon.HTTPError(falcon.HTTP_400, 'Invalid JSON', 'The JSON was incorrect.') try: # not validate.Request(api='custDetails', request=input_dict): if False: output_dict["data"].update({ "error": 1, "message": errors["json"] }) resp.body = json.dumps(output_dict) else: # , filename='mysql-slave.config') # setting an instance of DB class db = DB(input_dict["msgHeader"]["authLoginID"]) #dbw = DB(input_dict["msgHeader"]["authLoginID"]) val_error = validate(db).basicChecks( token=input_dict["msgHeader"] ["authToken"]) # change from dbw to db if val_error: output_dict["data"].update({ "error": 1, "message": val_error }) resp.body = json.dumps(output_dict) else: comp = Table("mw_company_master", schema="mint_loan") mapp = Table("mw_company_city_mapping", schema="mint_loan") citym = Table("mw_city_master", schema="mint_loan") q = Query.from_(comp).join(mapp, how=JoinType.left).on( comp.SHORT_NAME == mapp.COMPANY_SHORT_NAME).join( citym, how=JoinType.left) cities = db.runQuery( q.on(citym.CITY_ID == mapp.CITY_ID).select( citym.CITY).where(comp.DISPLAY_NAME == input_dict["data"]["company"])) cities = [ ele["CITY"] for ele in cities["data"] if ele["CITY"] ] #token = generate(db).AuthToken() if True: # token["updated"]: output_dict["data"]["citiesAvailable"] = cities output_dict["data"].update({ "error": 0, "message": success }) # token["token"] output_dict["msgHeader"]["authToken"] = input_dict[ "msgHeader"]["authToken"] else: output_dict["data"].update({ "error": 1, "message": errors["token"] }) resp.body = json.dumps(output_dict) #utils.logger.debug("Response: " + json.dumps(output_dict["msgHeader"]) + "\n", extra=logInfo) db._DbClose_() # dbw._DbClose_() change except Exception as ex: #utils.logger.error("ExecutionError: ", extra=logInfo, exc_info=True) # falcon.HTTPError(falcon.HTTP_400,'Invalid JSON', 'The JSON was incorrect.') raise