def get_phonenoinoperator(phone_no, operator): try: op = operator.upper() opid = "" count = [] con = DBConnectivity.create_connection() cur = DBConnectivity.create_cursor(con) cur2 = DBConnectivity.create_cursor(con) cur.execute( "select op_id from operator where upper(op_name)=:op_name and upper(op_id) like 'M%'", {"op_name": op.upper()}) for cid in cur: opid = cid[0] cur2.execute( "select phone_no from customer_mobile where op_id=:op_id and phone_no=:pho", { "op_id": opid.upper(), "pho": phone_no }) for ph in cur2: phone = customer_mobile() phone.set_phone_no(ph) count.append(phone) if (len(count) != 0): return count return False finally: cur.close() cur2.close() con.commit() con.close()
def get_conn_type(phone_no): try: conn_list = [] con = DBConnectivity.create_connection() cur = DBConnectivity.create_cursor(con) cur.execute( "select conn_type from customer_mobile where phone_no=:ph_no", {"ph_no": phone_no}) for counter in cur: ctype = customer_mobile() ctype.set_conn_type(counter) conn_list.append(ctype) if (len(conn_list) != 0): return (conn_list[0].get_conn_type())[0] return False finally: cur.close() con.commit() con.close()
def get_mobile_no(mobile_no): try: con = DBConnectivity.create_connection() cur = DBConnectivity.create_cursor(con) list_of_mobileno = [] cur.execute("select phone_no from customer_mobile where phone_no=:ph", {"ph": mobile_no}) for mobileno in cur: mob_no = customer_mobile() mob_no.set_phone_no(mobileno) list_of_mobileno.append(mob_no) return list_of_mobileno finally: cur.close() con.commit() con.close()
def get_conn_type(mobile_no): try: con = DBConnectivity.create_connection() cur = DBConnectivity.create_cursor(con) list_of_conn_type = [] cur.execute( "select conn_type from customer_mobile where phone_no=:mob_no", {"mob_no": mobile_no}) for conn_type in cur: c_type = customer_mobile() c_type.set_conn_type(conn_type) list_of_conn_type.append(c_type) return (list_of_conn_type[0].get_conn_type())[0] finally: cur.close() con.commit() con.close()
def get_mobile_in_operator(mobile_no, operator): try: con = DBConnectivity.create_connection() cur1 = DBConnectivity.create_cursor(con) cur2 = DBConnectivity.create_cursor(con) list_of_mobile_in_operator = [] x = "0" cur1.execute( "select op_id from operator where upper(op_name)=:op and upper(op_id) like 'M%'", {"op": operator.upper()}) for i in cur1: x = i[0] cur2.execute( "select phone_no from customer_mobile where phone_no=:mob_no and upper(op_id)=:operator_id", { "mob_no": int(mobile_no), "operator_id": x.upper() }) for mobileno in cur2: mobile_no = customer_mobile() mobile_no.set_phone_no(mobileno) list_of_mobile_in_operator.append(mobile_no) return list_of_mobile_in_operator finally: cur1.close() cur2.close() con.commit() con.close()