def login(username, password): try: con = DBConnectivity.create_connection() cur = DBConnectivity.create_cursor(con) cur.execute( "select username,password,cityname,area from registration where username=:category1 and password=:category2", { "category1": username, "category2": password }) for username, password, cityname, area in cur: ''' In this loop, we are creating a registration object for every row and setting the values from the row into the registration object ''' customer = Customer() customer.set_username(username) customer.set_password(password) customer.set_city(cityname) customer.set_area(area) ''' Here were are adding the new registration to a list ''' return customer finally: cur.close() con.close()
def validate_username(username): try: con = DBConnectivity.create_connection() cur = DBConnectivity.create_cursor(con) list_of_name = [] cur.execute("select username from registration") for username in cur: ''' In this loop, we are creating a registration object for every row and setting the values from the row into the registration object ''' customer = Customer() customer.set_username(username) ''' Here were are adding the new registration to a list ''' list_of_name.append(username) return list_of_name finally: cur.close() con.close()