I have this function, which I am obtaining all the names from employees, the problem is, i only get the last record, not all of them I want all these names: Maria, John, Sam but it returns only Sam. I am using a class because I need to follow the code's structure the last programmer did.
My class:
class name_data:
def __init__(self):
self.name = 'null'
def getNames (conn):
cursor = conn.cursor()
query = """SELECT NAME FROM PERSON"""
cursor.execute(query)
row = cursor.fetchone()
while row:
sent_person = name_data()
sent_person.name = row[0]
row = cursor.fetchone()
return sent_person