def exec_user_register(self, user): accountdao = account_dao(user_details_dao.database_connection, user_details_dao.dbCursor) accountInfo = account_info(None, None, None, None, None) acountResp = accountdao.register_Account(accountInfo) msg = "" if (acountResp != -1): if not self.check_user_registered_already(user.username) == True: my_logger.info('---inside user Dao for registration---') try: sql = "INSERT INTO user_info(user_id,user_name,first_name,last_name,date_of_birth,address,password,pin_code,gender,account_id) \ VALUES ('%d','%s', '%s', '%s', '%s', '%s','%s','%s','%s',%d )" % \ (user.userid,user.username,user.firstname,user.lastname,user.dob,user.address,user.password,user.pincode,user.gender,acountResp) my_logger.info(sql) user_details_dao.dbCursor.execute(sql) user_details_dao.database_connection.commit() my_logger.info(user) msg = "Passed" except Exception as e: user_details_dao.database_connection.rollback() my_logger.exception("Unable to insert records:-") msg = "500" finally: if (user_details_dao.database_connection != None): user_details_dao.database_connection.close() if (user_details_dao.dbCursor != None): dbCursor = None else: msg = "User already Registered" else: msg = "500" return msg
def getAccountFullInfo(self, accountId): accountdao = account_dao(user_details_dao.database_connection, user_details_dao.dbCursor) acountResp = accountdao.get_Account_details(None, accountId) if (acountResp != None): return acountResp # finally: # if(user_details_dao.database_connection != None): # user_details_dao.database_connection.close() # if(user_details_dao.dbCursor != None): # dbCursor = None return None
def initiate_balance_update(self, transaction, type): amt = 0.0 msgarr = None accountdao = account_dao(transaction_dao_access.database_connection, transaction_dao_access.dbcursor) sql = "" my_logger.info('---initiate_balance_update being initiated---') msg = accountdao.get_Account_details( transaction.recipient_account_number, None) if (msg != None and msg != "500"): msgarr = msg.split(",") msg = msgarr[4] amt = float(transaction.amount) + float(msg) sql = "UPDATE account_info SET current_balance = %.2f where account_no ='%s'" % \ (amt,transaction.recipient_account_number) # else: # sql = "UPDATE account_info SET current_balance = %.2f where account_id =%d" % \ # (amt,transaction.recipient_account_number) transaction_dao_access.dbcursor.execute(sql) transaction_dao_access.database_connection.commit() my_logger.info('--balance_updated--') sql = "" amt = 0.0 if (type == "transfer"): my_logger.info('---inside transfer method--') msg = accountdao.get_Account_details( None, config_meta.Session_userAccountId) if (msg != None and msg != "500"): msgarr = msg.split(",") msg = msgarr[4] amt = float(msg) - float(transaction.amount) # res=accountdao.get_Account_details(transaction.recipient_account_number) # if(res!=None and res!="500"): # receipent_amt=receipent_amt + float(res) sql = "UPDATE account_info SET current_balance = %f where account_id =%d" % \ (amt,int(config_meta.Session_userAccountId)) my_logger.info(sql) transaction_dao_access.dbcursor.execute(sql) transaction_dao_access.database_connection.commit() msgarr = None my_logger.info("---balance updation completed --")